2727use Illuminate \Auth \Access \AuthorizationException ;
2828use Illuminate \Auth \AuthenticationException ;
2929use Illuminate \Contracts \Container \Container ;
30+ use Illuminate \Contracts \Debug \ExceptionHandler ;
3031use Illuminate \Foundation \Exceptions \Handler as ExceptionsHandler ;
3132use Negotiation \Negotiator ;
3233use Symfony \Component \HttpFoundation \Exception \RequestExceptionInterface ;
@@ -54,6 +55,7 @@ public function __construct(
5455 private readonly ?array $ exceptionToStatus = null ,
5556 private readonly ?bool $ debug = false ,
5657 private readonly ?array $ errorFormats = null ,
58+ private readonly ?ExceptionHandler $ decorated = null ,
5759 ) {
5860 $ this ->resourceMetadataCollectionFactory = $ resourceMetadataCollectionFactory ;
5961 $ this ->negotiator = $ negotiator ;
@@ -65,7 +67,7 @@ public function render($request, \Throwable $exception)
6567 $ apiOperation = $ this ->initializeOperation ($ request );
6668
6769 if (!$ apiOperation ) {
68- return parent ::render ($ request , $ exception );
70+ return $ this -> decorated ? $ this -> decorated -> render ( $ request , $ exception ) : parent ::render ($ request , $ exception );
6971 }
7072
7173 $ formats = $ this ->errorFormats ?? ['jsonproblem ' => ['application/problem+json ' ]];
@@ -157,9 +159,12 @@ public function render($request, \Throwable $exception)
157159 }
158160
159161 try {
160- return $ this ->apiPlatformController ->__invoke ($ dup );
162+ $ response = $ this ->apiPlatformController ->__invoke ($ dup );
163+ $ this ->decorated ->render ($ dup , $ exception );
164+
165+ return $ response ;
161166 } catch (\Throwable $ e ) {
162- return parent ::render ($ dup , $ e );
167+ return $ this -> decorated ? $ this -> decorated -> render ( $ request , $ exception ) : parent ::render ($ request , $ exception );
163168 }
164169 }
165170
0 commit comments