thephpleague/booboo

Treating all errors as fatal: $fatalErrors vs treatErrorsAsExceptions()

Closed this issue · 1 comments

In development, I want to treat all errors as fatal. (as opposed to production, where I want to log and continue for warnings and notices.)

But Runner::treatErrorsAsExceptions(true) didn't do what I thought it would do - if I configure it like this:

        $runner = new Runner();

        $runner->treatErrorsAsExceptions(true);

        $formatter = new HtmlTableFormatter();

        $formatter->setErrorLimit(E_ALL);

        $runner->pushFormatter($formatter);

        $runner->register();

Now, for some reason, the Runner definitely doesn't "treat errors as exceptions", which I took as, "treat errors the same way you treat exceptions", which isn't what happens - instead, it doesn't handle errors or exceptions, at all, and the errors fall through to e.g. xdebug.

So it's not doing anything at all? If that's the behavior I wanted, couldn't I just skip registering the Runner in the first place? Am I missing something?

What I actually wanted, is probably just to set Runner::$fatalErrors so that all errors would be treated as fatal - that is, I want even a warning or notice to stop the program; we want to force developers to fix warnings and notices immediately. Unfortunately, you forgot to add a setter for that option - should I really need to extend the Runner just to change that setting? :-)

(It would be a huge time-saver if the documentation included real-world examples of typical error-handling and formatting setups for development and production, e.g. warnings and notices logged to a PSR logger in production, friendly error page for exceptions and errors; fall-through to xdebug (or a formatter) in development, halting on warnings and notices.)

Forget it, this is caused by zend-diactoros which uses a try/catch for all exceptions - thus no exceptions ever bubble to the exception-handler installed by booboo.