2021-06-26 11:23:15 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Exceptions;
|
2015-09-04 12:16:58 -04:00
|
|
|
|
2021-05-08 14:00:09 -04:00
|
|
|
use Exception;
|
|
|
|
use Illuminate\Contracts\Support\Responsable;
|
2015-09-04 12:16:58 -04:00
|
|
|
|
2021-05-08 14:00:09 -04:00
|
|
|
class NotifyException extends Exception implements Responsable
|
|
|
|
{
|
2015-09-04 12:16:58 -04:00
|
|
|
public $message;
|
|
|
|
public $redirectLocation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NotifyException constructor.
|
|
|
|
*/
|
2021-06-26 11:23:15 -04:00
|
|
|
public function __construct(string $message, string $redirectLocation = '/')
|
2015-09-04 12:16:58 -04:00
|
|
|
{
|
|
|
|
$this->message = $message;
|
|
|
|
$this->redirectLocation = $redirectLocation;
|
|
|
|
parent::__construct();
|
|
|
|
}
|
2021-05-08 14:00:09 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the response for this type of exception.
|
2021-06-26 11:23:15 -04:00
|
|
|
*
|
2021-05-08 14:00:09 -04:00
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function toResponse($request)
|
|
|
|
{
|
|
|
|
$message = $this->getMessage();
|
|
|
|
|
|
|
|
if (!empty($message)) {
|
|
|
|
session()->flash('error', $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect($this->redirectLocation);
|
|
|
|
}
|
2018-01-28 11:58:52 -05:00
|
|
|
}
|