]> BookStack Code Mirror - bookstack/blobdiff - app/Exceptions/NotifyException.php
Added front-end toggle and testing of inline attachments
[bookstack] / app / Exceptions / NotifyException.php
index 4f810596099cf2132093677b571ce40bf44a5aa8..efca625708b75ef2509d4f9790664c8ab3c18d24 100644 (file)
@@ -1,8 +1,10 @@
 <?php namespace BookStack\Exceptions;
 
-class NotifyException extends \Exception
-{
+use Exception;
+use Illuminate\Contracts\Support\Responsable;
 
+class NotifyException extends Exception implements Responsable
+{
     public $message;
     public $redirectLocation;
 
@@ -15,4 +17,19 @@ class NotifyException extends \Exception
         $this->redirectLocation = $redirectLocation;
         parent::__construct();
     }
+
+    /**
+     * Send the response for this type of exception.
+     * @inheritdoc
+     */
+    public function toResponse($request)
+    {
+        $message = $this->getMessage();
+
+        if (!empty($message)) {
+            session()->flash('error', $message);
+        }
+
+        return redirect($this->redirectLocation);
+    }
 }