@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | * @param Exception $exception |
33 | 33 | * @return void |
34 | 34 | */ |
35 | - protected function transformException(Exception $exception) |
|
35 | + protected function transformException( Exception $exception ) |
|
36 | 36 | { |
37 | - if (Request::capture()->wantsJson()) { |
|
38 | - $this->transformAuthException($exception); |
|
39 | - $this->transformEloquentException($exception); |
|
40 | - $this->transformValidationException($exception); |
|
37 | + if ( Request::capture()->wantsJson() ) { |
|
38 | + $this->transformAuthException( $exception ); |
|
39 | + $this->transformEloquentException( $exception ); |
|
40 | + $this->transformValidationException( $exception ); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @throws UnauthenticatedException |
50 | 50 | * @throws UnauthorizedException |
51 | 51 | */ |
52 | - protected function transformAuthException(Exception $exception) |
|
52 | + protected function transformAuthException( Exception $exception ) |
|
53 | 53 | { |
54 | - if ($exception instanceof AuthenticationException) { |
|
54 | + if ( $exception instanceof AuthenticationException ) { |
|
55 | 55 | throw new UnauthenticatedException(); |
56 | 56 | } |
57 | 57 | |
58 | - if ($exception instanceof AuthorizationException) { |
|
58 | + if ( $exception instanceof AuthorizationException ) { |
|
59 | 59 | throw new UnauthorizedException(); |
60 | 60 | } |
61 | 61 | } |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | * @throws ResourceNotFoundException |
69 | 69 | * @throws RelationNotFoundException |
70 | 70 | */ |
71 | - protected function transformEloquentException(Exception $exception) |
|
71 | + protected function transformEloquentException( Exception $exception ) |
|
72 | 72 | { |
73 | - if ($exception instanceof ModelNotFoundException) { |
|
73 | + if ( $exception instanceof ModelNotFoundException ) { |
|
74 | 74 | throw new ResourceNotFoundException(); |
75 | 75 | } |
76 | 76 | |
77 | - if ($exception instanceof RelationNotFoundException) { |
|
77 | + if ( $exception instanceof RelationNotFoundException ) { |
|
78 | 78 | throw new RelationNotFoundException(); |
79 | 79 | } |
80 | 80 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | * @return void |
87 | 87 | * @throws ValidationFailedException |
88 | 88 | */ |
89 | - protected function transformValidationException(Exception $exception) |
|
89 | + protected function transformValidationException( Exception $exception ) |
|
90 | 90 | { |
91 | - if ($exception instanceof ValidationException) { |
|
92 | - throw new ValidationFailedException($exception->validator); |
|
91 | + if ( $exception instanceof ValidationException ) { |
|
92 | + throw new ValidationFailedException( $exception->validator ); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | * @param ApiException $exception |
100 | 100 | * @return JsonResponse |
101 | 101 | */ |
102 | - protected function renderApiError(ApiException $exception):JsonResponse |
|
102 | + protected function renderApiError( ApiException $exception ):JsonResponse |
|
103 | 103 | { |
104 | - return app('responder.error') |
|
105 | - ->setError($exception->getErrorCode(), $exception->getMessage()) |
|
106 | - ->addData($exception->getData() ?: []) |
|
107 | - ->respond($exception->getStatusCode()); |
|
104 | + return app( 'responder.error' ) |
|
105 | + ->setError( $exception->getErrorCode(), $exception->getMessage() ) |
|
106 | + ->addData( $exception->getData() ?: [ ] ) |
|
107 | + ->respond( $exception->getStatusCode() ); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | \ No newline at end of file |