1 | <?php |
||
2 | |||
3 | namespace App\Exceptions; |
||
4 | |||
5 | use Exception; |
||
6 | use Illuminate\Auth\Access\AuthorizationException; |
||
7 | use Illuminate\Auth\AuthenticationException; |
||
8 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
||
9 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
||
10 | use Illuminate\Session\TokenMismatchException; |
||
11 | use Illuminate\Validation\ValidationException; |
||
12 | use Symfony\Component\HttpKernel\Exception\HttpException; |
||
13 | |||
14 | class Handler extends ExceptionHandler |
||
15 | { |
||
16 | /** |
||
17 | * A list of the exception types that are not reported. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $dontReport = [ |
||
22 | AuthenticationException::class, |
||
23 | AuthorizationException::class, |
||
24 | HttpException::class, |
||
25 | ModelNotFoundException::class, |
||
26 | TokenMismatchException::class, |
||
27 | ValidationException::class, |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * A list of the inputs that are never flashed for validation exceptions. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $dontFlash = [ |
||
36 | 'password', |
||
37 | 'password_confirmation', |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * Report or log an exception. |
||
42 | * |
||
43 | * @param \Exception $exception |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function report(Exception $exception) |
||
48 | { |
||
49 | if (app()->bound('sentry') && $this->shouldReport($exception)) { |
||
50 | app('sentry')->captureException($exception); |
||
0 ignored issues
–
show
|
|||
51 | } |
||
52 | |||
53 | parent::report($exception); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Render an exception into an HTTP response. |
||
58 | * |
||
59 | * @param \Illuminate\Http\Request $request |
||
60 | * @param \Exception $exception |
||
61 | * |
||
62 | * @return \Illuminate\Http\Response |
||
63 | */ |
||
64 | public function render($request, Exception $exception) |
||
65 | { |
||
66 | return parent::render($request, $exception); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Convert an authentication exception into an unauthenticated response. |
||
71 | * |
||
72 | * @param \Illuminate\Http\Request $request |
||
73 | * @param \Illuminate\Auth\AuthenticationException $exception |
||
74 | * |
||
75 | * @return \Illuminate\Http\Response |
||
76 | */ |
||
77 | protected function unauthenticated($request, AuthenticationException $exception) |
||
78 | { |
||
79 | if ($request->expectsJson()) { |
||
80 | return response()->json(['error' => 'Unauthenticated.'], 401); |
||
0 ignored issues
–
show
|
|||
81 | } |
||
82 | |||
83 | return redirect()->guest('login'); |
||
0 ignored issues
–
show
|
|||
84 | } |
||
85 | } |
||
86 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.