X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..refs/pull/5280/head:/app/Exceptions/PrettyException.php diff --git a/app/Exceptions/PrettyException.php b/app/Exceptions/PrettyException.php index 33c1471f2..606085231 100644 --- a/app/Exceptions/PrettyException.php +++ b/app/Exceptions/PrettyException.php @@ -4,27 +4,21 @@ namespace BookStack\Exceptions; use Exception; use Illuminate\Contracts\Support\Responsable; +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -class PrettyException extends Exception implements Responsable +class PrettyException extends Exception implements Responsable, HttpExceptionInterface { - /** - * @var ?string - */ - protected $subtitle = null; - - /** - * @var ?string - */ - protected $details = null; + protected ?string $subtitle = null; + protected ?string $details = null; /** * Render a response for when this exception occurs. * - * @inheritdoc + * {@inheritdoc} */ public function toResponse($request) { - $code = ($this->getCode() === 0) ? 500 : $this->getCode(); + $code = $this->getStatusCode(); return response()->view('errors.' . $code, [ 'message' => $this->getMessage(), @@ -46,4 +40,20 @@ class PrettyException extends Exception implements Responsable return $this; } + + /** + * Get the desired HTTP status code for this exception. + */ + public function getStatusCode(): int + { + return ($this->getCode() === 0) ? 500 : $this->getCode(); + } + + /** + * Get the desired HTTP headers for this exception. + */ + public function getHeaders(): array + { + return []; + } }