Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
Handler | |
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
3.58 | |
0.00% |
0 / 1 |
register | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
render | |
50.00% |
2 / 4 |
|
0.00% |
0 / 1 |
2.50 |
1 | <?php |
2 | |
3 | namespace App\Exceptions; |
4 | |
5 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
6 | use Throwable; |
7 | |
8 | class Handler extends ExceptionHandler |
9 | { |
10 | /** |
11 | * A list of the exception types that are not reported. |
12 | * |
13 | */ |
14 | protected $dontReport = [ |
15 | // |
16 | ]; |
17 | |
18 | /** |
19 | * A list of the inputs that are never flashed for validation exceptions. |
20 | * |
21 | */ |
22 | protected $dontFlash = [ |
23 | 'current_password', |
24 | 'password', |
25 | 'password_confirmation', |
26 | ]; |
27 | |
28 | /** |
29 | * Register the exception handling callbacks for the application. |
30 | * |
31 | * @return void |
32 | */ |
33 | public function register() |
34 | { |
35 | $this->reportable(function (Throwable $e) { |
36 | // |
37 | }); |
38 | } |
39 | |
40 | /** |
41 | * Override of render() to return nicer responses when custom middelware |
42 | * throws errors. |
43 | * |
44 | * @param \Illuminate\Http\Request $request |
45 | * @param Throwable $exception |
46 | */ |
47 | public function render($request, Throwable $exception) |
48 | { |
49 | if ($exception->getMessage() == "rootonly") { |
50 | return response()->json([ |
51 | "error" => "Root Only", |
52 | "details" => null, |
53 | ], $exception->getStatusCode()); // @phpstan-ignore-line |
54 | } |
55 | return parent::render($request, $exception); |
56 | } |
57 | } |