File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ public function __construct(?string $errorHandlingPath = null)
3131 public function async_invoke (HttpContext $ context , RequestDelegate $ next ): void
3232 {
3333 try {
34+ // Must throw the previous error exception if it exists, before catching the next one.
35+ $ error = $ context ->Items ['ErrorException ' ] ?? null ;
36+ if ($ error ) {
37+ throw $ error ;
38+ }
3439 await ($ next ($ context ));
3540 } catch (Throwable $ error ) {
3641 if (PHP_SAPI == 'cli ' ) {
Original file line number Diff line number Diff line change @@ -25,13 +25,18 @@ class ExceptionPageMiddleware implements IMiddleware
2525 public function async_invoke (HttpContext $ context , RequestDelegate $ next ): void
2626 {
2727 try {
28+ // Must throw the previous error exception if it exists, before catching the next one.
29+ $ error = $ context ->Items ['ErrorException ' ] ?? null ;
30+ if ($ error ) {
31+ throw $ error ;
32+ }
2833 await ($ next ($ context ));
2934 } catch (Throwable $ error ) {
3035 if (PHP_SAPI == 'cli ' ) {
3136 throw new $ error ;
3237 }
3338
34- // Need to remove the previous headers and body of the response to send only the error report.
39+ // Must remove the previous headers and body of the response to send only the error report.
3540 $ context ->Response ->Body ->truncate (0 );
3641 $ headerNames = array_keys ($ context ->Response ->Headers ->getAll ());
3742 foreach ($ headerNames as $ name ) {
Original file line number Diff line number Diff line change @@ -45,10 +45,15 @@ public function start(Closure $configure): void
4545 return ;
4646 }
4747
48+ $ context = $ this ->provider ->getService (HttpContext::class);
4849 try {
50+ // Must throw the previous error exception if it exists, before catching the next one.
51+ $ error = $ context ->Items ['ErrorException ' ] ?? null ;
52+ if ($ error ) {
53+ throw $ error ;
54+ }
4955 $ configure ($ this ->appBuilder );
5056 } catch (\Throwable $ error ) {
51- $ context = $ this ->provider ->getService (HttpContext::class);
5257 $ context ->Items ->add ('ErrorException ' , $ error );
5358 }
5459
You can’t perform that action at this time.
0 commit comments