filp / whoops

PHP errors for cool kids
http://filp.github.io/whoops/
MIT License
13.19k stars 604 forks source link

Ignore specific exceptions #763

Closed JoyceBabu closed 3 months ago

JoyceBabu commented 3 months ago

How can I make Whoops ignore specific exceptions?

For example, my app throws an HttpException, which will be handled by the global error handler to display the appropriate error page. I have Whoops enabled only in development environment. This is causing Whoops handler to execute instead of the global handler.

How can I make Whoops ignore only HttpExceptions?

denis-sokolov commented 3 months ago

That’s the thing with global scope: it’s shared. There can be only one global error handler. If you request Whoops PrettyPageHandler to handle the error, it will do that. Whoops does not support being asked to handle the error and then not handling the error.

I can suggest two options: add your handler to be called from Whoops or call Whoops PrettyPageHandler from your handler. For former, you can use $whoops->pushHandler(function($exception) {}); and return \Whoops\Handler\Handler::DONE to stop. For latter, you can instantiate \Whoops\Handler\PrettyPageHandler yourself and call its ->handle.

JoyceBabu commented 3 months ago

I did end up calling my custom handler from Whoops.

But I think the second option is even better. Thank you.