We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Treat any warning as exception

Hi,

is there a way to configure framefork to automatically convert any errors/warnings/notices to an Exceptions? Or need we use old school PHP's method set_error_handler to catch them and then manually convert to exception like this

set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext) {
    // some processing, if any...
    throw new Exception(...);
}, -1);

?

Thanks )

That is the only way as warnings, notices etc. are PHP's internal behaviour. But I do agree that Phalcon could provide similiar functionality to declare error handler which will convert notice to exception etc - via IoC service.