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
14 protected $subtitle = null;
19 protected $details = null;
24 protected $headers = [];
27 * Render a response for when this exception occurs.
31 public function toResponse($request)
33 $code = $this->getStatusCode();
35 return response()->view('errors.' . $code, [
36 'message' => $this->getMessage(),
37 'subtitle' => $this->subtitle,
38 'details' => $this->details,
42 public function setSubtitle(string $subtitle): self
44 $this->subtitle = $subtitle;
49 public function setDetails(string $details): self
51 $this->details = $details;
57 * Get the desired HTTP status code for this exception.
59 public function getStatusCode(): int
61 return ($this->getCode() === 0) ? 500 : $this->getCode();
65 * Get the desired HTTP headers for this exception.
66 * @return array<mixed>
68 public function getHeaders(): array
70 return $this->headers;
74 * Set the desired HTTP headers for this exception.
75 * @param array<mixed> $headers
77 public function setHeaders(array $headers): void
79 $this->headers = $headers;