I have an application which runs on Slim3 in production. Currently I’m working on upgrading to Slim4.
I use an Error Handler and a Shutdown Handler as described in the Slim User Guide: https://www.slimframework.com/docs/v4/objects/application.html#advanced-custom-error-handler
The only difference is, that I use Twig and therefore I return a Twig-rendered HTML-String from the HttpErrorHandler. This works just fine.
The Problem is, when I have for example a 404 the HttpErrorHandler outputs the correct Twig-rendered Error-Page to the browser. If additionally there is a PHP Error in the code, the ShutdownHandler is triggered, which invokes the HttpErrorHandler and then this outputs an additional Twig-rendered Error-Page to the browser.
The second Error-Page is displayed under the first one in the browser.
At the moment I’m searching for ideas how to output only one error-page. Is it possible to detect the last error? Or can I suppress the output until the last error?
Thanks a lot for your support!