1 | <?php |
||
10 | class Handler extends ExceptionHandler |
||
11 | { |
||
12 | /** |
||
13 | * A list of the exception types that should not be reported. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $dontReport = [ |
||
18 | \Illuminate\Auth\AuthenticationException::class, |
||
19 | \Illuminate\Auth\Access\AuthorizationException::class, |
||
20 | \Symfony\Component\HttpKernel\Exception\HttpException::class, |
||
21 | \Illuminate\Database\Eloquent\ModelNotFoundException::class, |
||
22 | \Illuminate\Session\TokenMismatchException::class, |
||
23 | \Illuminate\Validation\ValidationException::class, |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * Report or log an exception. |
||
28 | * |
||
29 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||
30 | * |
||
31 | * @param \Exception $exception |
||
32 | * @return void |
||
33 | */ |
||
34 | public function report(Exception $exception) |
||
38 | |||
39 | /** |
||
40 | * Render an exception into an HTTP response. |
||
41 | * |
||
42 | * @param \Illuminate\Http\Request $request |
||
43 | * @param \Exception $exception |
||
44 | * @return \Illuminate\Http\Response |
||
45 | */ |
||
46 | public function render($request, Exception $exception) |
||
47 | { |
||
48 | if ($request->expectsJson() || $request->isJson() || $request->is(...config('pterodactyl.json_routes'))) { |
||
49 | $exception = $this->prepareException($exception); |
||
50 | |||
51 | if (config('app.debug') || $this->isHttpException($exception)) { |
||
52 | $displayError = $exception->getMessage(); |
||
53 | } else { |
||
54 | $displayError = 'An unhandled exception was encountered with this request.'; |
||
55 | } |
||
56 | |||
57 | $response = response()->json([ |
||
58 | 'error' => $displayError, |
||
59 | 'http_code' => (! $this->isHttpException($exception)) ?: $exception->getStatusCode(), |
||
60 | 'trace' => (! config('app.debug')) ? null : class_basename($exception) . ' in ' . $exception->getFile() . ' on line ' . $exception->getLine(), |
||
61 | ], ($this->isHttpException($exception)) ? $exception->getStatusCode() : 500, [], JSON_UNESCAPED_SLASHES); |
||
62 | |||
63 | parent::report($exception); |
||
|
|||
64 | } |
||
65 | |||
66 | return (isset($response)) ? $response : 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 | * @return \Illuminate\Http\Response |
||
75 | */ |
||
76 | protected function unauthenticated($request, AuthenticationException $exception) |
||
84 | } |
||
85 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.