27
27
use Illuminate \Auth \Access \AuthorizationException ;
28
28
use Illuminate \Auth \AuthenticationException ;
29
29
use Illuminate \Contracts \Container \Container ;
30
+ use Illuminate \Contracts \Debug \ExceptionHandler ;
30
31
use Illuminate \Foundation \Exceptions \Handler as ExceptionsHandler ;
31
32
use Negotiation \Negotiator ;
32
33
use Symfony \Component \HttpFoundation \Exception \RequestExceptionInterface ;
@@ -54,6 +55,7 @@ public function __construct(
54
55
private readonly ?array $ exceptionToStatus = null ,
55
56
private readonly ?bool $ debug = false ,
56
57
private readonly ?array $ errorFormats = null ,
58
+ private readonly ?ExceptionHandler $ decorated = null ,
57
59
) {
58
60
$ this ->resourceMetadataCollectionFactory = $ resourceMetadataCollectionFactory ;
59
61
$ this ->negotiator = $ negotiator ;
@@ -65,7 +67,7 @@ public function render($request, \Throwable $exception)
65
67
$ apiOperation = $ this ->initializeOperation ($ request );
66
68
67
69
if (!$ apiOperation ) {
68
- return parent ::render ($ request , $ exception );
70
+ return $ this -> decorated ? $ this -> decorated -> render ( $ request , $ exception ) : parent ::render ($ request , $ exception );
69
71
}
70
72
71
73
$ formats = $ this ->errorFormats ?? ['jsonproblem ' => ['application/problem+json ' ]];
@@ -157,9 +159,12 @@ public function render($request, \Throwable $exception)
157
159
}
158
160
159
161
try {
160
- return $ this ->apiPlatformController ->__invoke ($ dup );
162
+ $ response = $ this ->apiPlatformController ->__invoke ($ dup );
163
+ $ this ->decorated ->render ($ dup , $ exception );
164
+
165
+ return $ response ;
161
166
} catch (\Throwable $ e ) {
162
- return parent ::render ($ dup , $ e );
167
+ return $ this -> decorated ? $ this -> decorated -> render ( $ request , $ exception ) : parent ::render ($ request , $ exception );
163
168
}
164
169
}
165
170
0 commit comments