]> BookStack Code Mirror - bookstack/blob - app/Exceptions/NotifyException.php
efca625708b75ef2509d4f9790664c8ab3c18d24
[bookstack] / app / Exceptions / NotifyException.php
1 <?php namespace BookStack\Exceptions;
2
3 use Exception;
4 use Illuminate\Contracts\Support\Responsable;
5
6 class NotifyException extends Exception implements Responsable
7 {
8     public $message;
9     public $redirectLocation;
10
11     /**
12      * NotifyException constructor.
13      */
14     public function __construct(string $message, string $redirectLocation = "/")
15     {
16         $this->message = $message;
17         $this->redirectLocation = $redirectLocation;
18         parent::__construct();
19     }
20
21     /**
22      * Send the response for this type of exception.
23      * @inheritdoc
24      */
25     public function toResponse($request)
26     {
27         $message = $this->getMessage();
28
29         if (!empty($message)) {
30             session()->flash('error', $message);
31         }
32
33         return redirect($this->redirectLocation);
34     }
35 }