@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace App\Exceptions; |
4 | 4 | |
5 | -use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
|
5 | +use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
|
6 | 6 | use Throwable; |
7 | 7 | |
8 | 8 | class Handler extends ExceptionHandler |
@@ -7,69 +7,69 @@ |
||
7 | 7 | |
8 | 8 | class Handler extends ExceptionHandler |
9 | 9 | { |
10 | - /** |
|
11 | - * A list of the exception types that are not reported. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $dontReport = [ |
|
16 | - \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
17 | - ]; |
|
10 | + /** |
|
11 | + * A list of the exception types that are not reported. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $dontReport = [ |
|
16 | + \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
17 | + ]; |
|
18 | 18 | |
19 | - /** |
|
20 | - * A list of the inputs that are never flashed for validation exceptions. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $dontFlash = [ |
|
25 | - 'password', |
|
26 | - 'password_confirmation', |
|
27 | - ]; |
|
19 | + /** |
|
20 | + * A list of the inputs that are never flashed for validation exceptions. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $dontFlash = [ |
|
25 | + 'password', |
|
26 | + 'password_confirmation', |
|
27 | + ]; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Report or log an exception. |
|
31 | - * |
|
32 | - * @param \Throwable $exception |
|
33 | - * @return void |
|
34 | - * |
|
35 | - * @throws \Exception |
|
36 | - */ |
|
37 | - public function report(Throwable $exception) |
|
38 | - { |
|
39 | - parent::report($exception); |
|
40 | - } |
|
29 | + /** |
|
30 | + * Report or log an exception. |
|
31 | + * |
|
32 | + * @param \Throwable $exception |
|
33 | + * @return void |
|
34 | + * |
|
35 | + * @throws \Exception |
|
36 | + */ |
|
37 | + public function report(Throwable $exception) |
|
38 | + { |
|
39 | + parent::report($exception); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Render an exception into an HTTP response. |
|
44 | - * |
|
45 | - * @param \Illuminate\Http\Request $request |
|
46 | - * @param \Throwable $exception |
|
47 | - * @return \Symfony\Component\HttpFoundation\Response |
|
48 | - * |
|
49 | - * @throws \Throwable |
|
50 | - */ |
|
51 | - public function render($request, Throwable $exception) |
|
52 | - { |
|
53 | - if ($request->wantsJson()) { |
|
54 | - if ($e instanceof \Illuminate\Auth\AuthenticationException) { |
|
55 | - \ErrorHandler::unAuthorized(); |
|
56 | - } |
|
57 | - if ($e instanceof \Illuminate\Database\QueryException) { |
|
58 | - \ErrorHandler::dbQueryError(); |
|
59 | - } elseif ($e instanceof \predis\connection\connectionexception) { |
|
60 | - \ErrorHandler::redisNotRunning(); |
|
61 | - } elseif ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
62 | - \ErrorHandler::connectionError(); |
|
63 | - } elseif ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { |
|
64 | - $errors = $e->getStatusCode() === 404 ? 'not found' : $e->getMessage(); |
|
65 | - return \Response::json(['errors' => [$errors]], $e->getStatusCode()); |
|
66 | - } elseif ($e instanceof \Illuminate\Validation\ValidationException) { |
|
67 | - return \Response::json(['errors' => $e->errors()], 422); |
|
68 | - } elseif (! $e instanceof \Symfony\Component\ErrorHandler\Error\FatalError) { |
|
69 | - return parent::render($request, $e); |
|
70 | - } |
|
71 | - } |
|
42 | + /** |
|
43 | + * Render an exception into an HTTP response. |
|
44 | + * |
|
45 | + * @param \Illuminate\Http\Request $request |
|
46 | + * @param \Throwable $exception |
|
47 | + * @return \Symfony\Component\HttpFoundation\Response |
|
48 | + * |
|
49 | + * @throws \Throwable |
|
50 | + */ |
|
51 | + public function render($request, Throwable $exception) |
|
52 | + { |
|
53 | + if ($request->wantsJson()) { |
|
54 | + if ($e instanceof \Illuminate\Auth\AuthenticationException) { |
|
55 | + \ErrorHandler::unAuthorized(); |
|
56 | + } |
|
57 | + if ($e instanceof \Illuminate\Database\QueryException) { |
|
58 | + \ErrorHandler::dbQueryError(); |
|
59 | + } elseif ($e instanceof \predis\connection\connectionexception) { |
|
60 | + \ErrorHandler::redisNotRunning(); |
|
61 | + } elseif ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
62 | + \ErrorHandler::connectionError(); |
|
63 | + } elseif ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { |
|
64 | + $errors = $e->getStatusCode() === 404 ? 'not found' : $e->getMessage(); |
|
65 | + return \Response::json(['errors' => [$errors]], $e->getStatusCode()); |
|
66 | + } elseif ($e instanceof \Illuminate\Validation\ValidationException) { |
|
67 | + return \Response::json(['errors' => $e->errors()], 422); |
|
68 | + } elseif (! $e instanceof \Symfony\Component\ErrorHandler\Error\FatalError) { |
|
69 | + return parent::render($request, $e); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return parent::render($request, $e); |
|
74 | - } |
|
73 | + return parent::render($request, $e); |
|
74 | + } |
|
75 | 75 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | return \Response::json(['errors' => [$errors]], $e->getStatusCode()); |
66 | 66 | } elseif ($e instanceof \Illuminate\Validation\ValidationException) { |
67 | 67 | return \Response::json(['errors' => $e->errors()], 422); |
68 | - } elseif (! $e instanceof \Symfony\Component\ErrorHandler\Error\FatalError) { |
|
68 | + } elseif ( ! $e instanceof \Symfony\Component\ErrorHandler\Error\FatalError) { |
|
69 | 69 | return parent::render($request, $e); |
70 | 70 | } |
71 | 71 | } |
@@ -6,42 +6,42 @@ |
||
6 | 6 | |
7 | 7 | class ApiSkeletonServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->publishes([ |
|
17 | - __DIR__.'/Modules' => app_path('Modules'), |
|
18 | - __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | - __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | - __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | - __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | - __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | - __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | - __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | - __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | - __DIR__.'/../files/phpcs.xml' => base_path('/phpcs.xml'), |
|
27 | - __DIR__.'/../files/docker' => base_path('/docker'), |
|
28 | - __DIR__.'/../files/docker-compose.dev.yml' => base_path('/docker-compose.dev.yml'), |
|
29 | - __DIR__.'/../files/docker-compose.prod.yml' => base_path('/docker-compose.prod.yml'), |
|
30 | - __DIR__.'/../files/.dockerignore' => base_path('/.dockerignore'), |
|
31 | - ]); |
|
9 | + /** |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->publishes([ |
|
17 | + __DIR__.'/Modules' => app_path('Modules'), |
|
18 | + __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | + __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | + __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | + __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | + __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | + __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | + __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | + __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | + __DIR__.'/../files/phpcs.xml' => base_path('/phpcs.xml'), |
|
27 | + __DIR__.'/../files/docker' => base_path('/docker'), |
|
28 | + __DIR__.'/../files/docker-compose.dev.yml' => base_path('/docker-compose.dev.yml'), |
|
29 | + __DIR__.'/../files/docker-compose.prod.yml' => base_path('/docker-compose.prod.yml'), |
|
30 | + __DIR__.'/../files/.dockerignore' => base_path('/.dockerignore'), |
|
31 | + ]); |
|
32 | 32 | |
33 | - $this->publishes([ |
|
34 | - __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
35 | - ], 'config'); |
|
36 | - } |
|
33 | + $this->publishes([ |
|
34 | + __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
35 | + ], 'config'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Register any package services. |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function register() |
|
44 | - { |
|
45 | - // |
|
46 | - } |
|
38 | + /** |
|
39 | + * Register any package services. |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function register() |
|
44 | + { |
|
45 | + // |
|
46 | + } |
|
47 | 47 | } |