3 namespace BookStack\Exceptions;
6 use Illuminate\Contracts\Support\Responsable;
7 use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
9 class PrettyException extends Exception implements Responsable, HttpExceptionInterface
11 protected ?string $subtitle = null;
12 protected ?string $details = null;
15 * Render a response for when this exception occurs.
19 public function toResponse($request)
21 $code = $this->getStatusCode();
23 return response()->view('errors.' . $code, [
24 'message' => $this->getMessage(),
25 'subtitle' => $this->subtitle,
26 'details' => $this->details,
30 public function setSubtitle(string $subtitle): self
32 $this->subtitle = $subtitle;
37 public function setDetails(string $details): self
39 $this->details = $details;
45 * Get the desired HTTP status code for this exception.
47 public function getStatusCode(): int
49 return ($this->getCode() === 0) ? 500 : $this->getCode();
53 * Get the desired HTTP headers for this exception.
55 public function getHeaders(): array