@@ -13,7 +13,7 @@ |
||
13 | 13 | /** |
14 | 14 | * Get the Whoops Handler instance to use |
15 | 15 | * |
16 | - * @return \Whoops\Handler\Handler |
|
16 | + * @return callable |
|
17 | 17 | */ |
18 | 18 | protected function getWhoopsHandler() |
19 | 19 | { |
@@ -10,45 +10,45 @@ |
||
10 | 10 | |
11 | 11 | class WhoopsExceptionHandler extends Handler |
12 | 12 | { |
13 | - /** |
|
14 | - * Get the Whoops Handler instance to use |
|
15 | - * |
|
16 | - * @return \Whoops\Handler\Handler |
|
17 | - */ |
|
18 | - protected function getWhoopsHandler() |
|
19 | - { |
|
20 | - $ajaxResponse = (Request::ajax() || Request::wantsJson()); |
|
13 | + /** |
|
14 | + * Get the Whoops Handler instance to use |
|
15 | + * |
|
16 | + * @return \Whoops\Handler\Handler |
|
17 | + */ |
|
18 | + protected function getWhoopsHandler() |
|
19 | + { |
|
20 | + $ajaxResponse = (Request::ajax() || Request::wantsJson()); |
|
21 | 21 | |
22 | - return $ajaxResponse ? new JsonResponseHandler() : new PrettyPageHandler(); |
|
23 | - } |
|
22 | + return $ajaxResponse ? new JsonResponseHandler() : new PrettyPageHandler(); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Create a Whoops response for the given exception |
|
27 | - * |
|
28 | - * @param Exception $e |
|
29 | - * @return \Illuminate\Http\Response |
|
30 | - */ |
|
31 | - protected function convertExceptionToWhoops(Exception $e) |
|
32 | - { |
|
33 | - $whoops = new Whoops(); |
|
34 | - $whoops->pushHandler($this->getWhoopsHandler()); |
|
25 | + /** |
|
26 | + * Create a Whoops response for the given exception |
|
27 | + * |
|
28 | + * @param Exception $e |
|
29 | + * @return \Illuminate\Http\Response |
|
30 | + */ |
|
31 | + protected function convertExceptionToWhoops(Exception $e) |
|
32 | + { |
|
33 | + $whoops = new Whoops(); |
|
34 | + $whoops->pushHandler($this->getWhoopsHandler()); |
|
35 | 35 | |
36 | - $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500; |
|
37 | - $headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : []; |
|
36 | + $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500; |
|
37 | + $headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : []; |
|
38 | 38 | |
39 | - return response()->make($whoops->handleException($e), $statusCode, $headers); |
|
40 | - } |
|
39 | + return response()->make($whoops->handleException($e), $statusCode, $headers); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Create the default or a Whoops response for the given exception |
|
44 | - * |
|
45 | - * @param Exception $e |
|
46 | - * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response |
|
47 | - */ |
|
48 | - protected function convertExceptionToResponse(Exception $e) |
|
49 | - { |
|
50 | - return config('app.debug') |
|
51 | - ? $this->convertExceptionToWhoops($e) |
|
52 | - : parent::convertExceptionToResponse($e); |
|
53 | - } |
|
42 | + /** |
|
43 | + * Create the default or a Whoops response for the given exception |
|
44 | + * |
|
45 | + * @param Exception $e |
|
46 | + * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response |
|
47 | + */ |
|
48 | + protected function convertExceptionToResponse(Exception $e) |
|
49 | + { |
|
50 | + return config('app.debug') |
|
51 | + ? $this->convertExceptionToWhoops($e) |
|
52 | + : parent::convertExceptionToResponse($e); |
|
53 | + } |
|
54 | 54 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $whoops->pushHandler($this->getWhoopsHandler()); |
35 | 35 | |
36 | 36 | $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500; |
37 | - $headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : []; |
|
37 | + $headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : [ ]; |
|
38 | 38 | |
39 | 39 | return response()->make($whoops->handleException($e), $statusCode, $headers); |
40 | 40 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class WhoopsServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Overwrite the default ExceptionHandler |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function register() |
|
15 | - { |
|
16 | - $this->app->singleton(ExceptionHandler::class, WhoopsExceptionHandler::class); |
|
17 | - } |
|
9 | + /** |
|
10 | + * Overwrite the default ExceptionHandler |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function register() |
|
15 | + { |
|
16 | + $this->app->singleton(ExceptionHandler::class, WhoopsExceptionHandler::class); |
|
17 | + } |
|
18 | 18 | } |