3 namespace BookStack\Exceptions;
6 use Illuminate\Contracts\Support\Responsable;
8 class NotifyException extends Exception implements Responsable
11 public $redirectLocation;
14 public function __construct(string $message, string $redirectLocation = '/', int $status = 500)
16 $this->message = $message;
17 $this->redirectLocation = $redirectLocation;
18 $this->status = $status;
19 parent::__construct();
23 * Get the desired status code for this exception.
25 public function getStatus(): int
31 * Send the response for this type of exception.
35 public function toResponse($request)
37 $message = $this->getMessage();
39 // Front-end JSON handling. API-side handling managed via handler.
40 if ($request->wantsJson()) {
41 return response()->json(['error' => $message], 403);
44 if (!empty($message)) {
45 session()->flash('error', $message);
48 return redirect($this->redirectLocation);