1 | <?php |
||
26 | trait HandlesApiErrors |
||
27 | { |
||
28 | /** |
||
29 | * Transform a Laravel exception into an API exception. |
||
30 | * |
||
31 | * @param Exception $exception |
||
32 | * @return void |
||
33 | */ |
||
34 | protected function transformException(Exception $exception) |
||
40 | |||
41 | /** |
||
42 | * Transform a Laravel auth exception into an API exception. |
||
43 | * |
||
44 | * @param Exception $exception |
||
45 | * @return void |
||
46 | * @throws UnauthenticatedException |
||
47 | * @throws UnauthorizedException |
||
48 | */ |
||
49 | protected function transformAuthException(Exception $exception) |
||
59 | |||
60 | /** |
||
61 | * Transform an Eloquent exception into an API exception. |
||
62 | * |
||
63 | * @param Exception $exception |
||
64 | * @return void |
||
65 | * @throws ResourceNotFoundException |
||
66 | * @throws RelationNotFoundException |
||
67 | */ |
||
68 | protected function transformEloquentException(Exception $exception) |
||
78 | |||
79 | /** |
||
80 | * Transform a Laravel validation exception into an API exception. |
||
81 | * |
||
82 | * @param Exception $exception |
||
83 | * @return void |
||
84 | * @throws ValidationFailedException |
||
85 | */ |
||
86 | protected function transformValidationException(Exception $exception) |
||
92 | |||
93 | /** |
||
94 | * Renders any API exception into a JSON error response. |
||
95 | * |
||
96 | * @param ApiException $exception |
||
97 | * @return JsonResponse |
||
98 | */ |
||
99 | protected function renderApiError(ApiException $exception):JsonResponse |
||
106 | } |