2121use CloudCreativity \LaravelJsonApi \Contracts \Exceptions \ExceptionParserInterface ;
2222use CloudCreativity \LaravelJsonApi \Document \Error \Translator ;
2323use CloudCreativity \LaravelJsonApi \Encoder \Neomerx \Document \Errors as NeomerxErrors ;
24- use Exception ;
2524use Illuminate \Auth \Access \AuthorizationException ;
2625use Illuminate \Auth \AuthenticationException ;
2726use Illuminate \Http \Response ;
2827use Illuminate \Session \TokenMismatchException ;
2928use Illuminate \Validation \ValidationException as IlluminateValidationException ;
3029use Neomerx \JsonApi \Contracts \Document \ErrorInterface ;
3130use Neomerx \JsonApi \Document \Error ;
32- use Neomerx \JsonApi \Exceptions \JsonApiException ;
33- use Symfony \Component \HttpKernel \Exception \HttpException ;
31+ use Neomerx \JsonApi \Exceptions \JsonApiException as NeomerxJsonApiException ;
3432use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
3533
3634/**
@@ -62,6 +60,10 @@ public function __construct(Translator $translator)
6260 public function parse (\Throwable $ e ): DocumentInterface
6361 {
6462 if ($ e instanceof JsonApiException) {
63+ return $ e ->getErrors ();
64+ }
65+
66+ if ($ e instanceof NeomerxJsonApiException) {
6567 return NeomerxErrors::cast ($ e );
6668 }
6769
@@ -95,7 +97,7 @@ protected function getErrors(\Throwable $e): array
9597 return [$ this ->translator ->tokenMismatch ()];
9698 }
9799
98- if ($ e instanceof HttpException ) {
100+ if ($ e instanceof HttpExceptionInterface ) {
99101 return [$ this ->getHttpError ($ e )];
100102 }
101103
@@ -112,10 +114,10 @@ protected function getValidationError(IlluminateValidationException $e): array
112114 }
113115
114116 /**
115- * @param HttpException $e
117+ * @param HttpExceptionInterface $e
116118 * @return ErrorInterface
117119 */
118- protected function getHttpError (HttpException $ e ): ErrorInterface
120+ protected function getHttpError (HttpExceptionInterface $ e ): ErrorInterface
119121 {
120122 $ status = $ e ->getStatusCode ();
121123 $ title = $ this ->getDefaultTitle ($ status );
0 commit comments