]> BookStack Code Mirror - bookstack/blob - app/Exceptions/PrettyException.php
Apply fixes from StyleCI
[bookstack] / app / Exceptions / PrettyException.php
1 <?php
2
3 namespace BookStack\Exceptions;
4
5 use Exception;
6 use Illuminate\Contracts\Support\Responsable;
7
8 class PrettyException extends Exception implements Responsable
9 {
10     /**
11      * @var ?string
12      */
13     protected $subtitle = null;
14
15     /**
16      * @var ?string
17      */
18     protected $details = null;
19
20     /**
21      * Render a response for when this exception occurs.
22      *
23      * @inheritdoc
24      */
25     public function toResponse($request)
26     {
27         $code = ($this->getCode() === 0) ? 500 : $this->getCode();
28
29         return response()->view('errors.' . $code, [
30             'message'  => $this->getMessage(),
31             'subtitle' => $this->subtitle,
32             'details'  => $this->details,
33         ], $code);
34     }
35
36     public function setSubtitle(string $subtitle): self
37     {
38         $this->subtitle = $subtitle;
39
40         return $this;
41     }
42
43     public function setDetails(string $details): self
44     {
45         $this->details = $details;
46
47         return $this;
48     }
49 }