Re: set_error_handler() and fatal errors?
| From: | Zeev Suraski | Date: | Wed, 13 Dec 2000 18:57:22 +0000 |
| Subject: | Re: set_error_handler() and fatal errors? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-41206@lists.php.net to get a copy of this message | ||
At 20:39 13/12/2000, Rasmus Lerdorf wrote:
I think set_error_handler() should be able to catch fatal errors as well as the non-fatal ones if possible. The current documentation indicates that fatal errors can be caught, but it doesn't actually work. This script for example: <? error_reporting(E_ERROR|E_WARNING|E_PARSE|E_NOTICE|E_CORE_ERROR|E_CORE_WARNING|E_COMPILE_ERROR|E_COMPILE_WARNING|E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE); function myHandler($errno, $errstr, $errfile, $errline) {We'll have to address this in the documentation. Fatal errors cannot be trapped in userland because the engine may not be in a stable state - and we should bail out as quickly and as cleanly as possible. We might want to create a new class of errors, errors which are fatal unless they're trapped. I think that a call to an undefined function can belong to such a class. Zeev -- Zeev Suraski <zeev@zend.com> CTO, Zend Technologies Ltd. http://www.zend.com/echo "$errno: $errstr on line $errline in $errfile\n";} set_error_handler("myHandler"); echo $a; blah(); ?> Gives me: 8: Undefined variable: a on line 9 in t <br> <b>Fatal error</b>: Call to undefined function: blah() in <b>t</b> on line <b>10</b><br> which shows that MyHandler() was only called for the undefined variable problem. If we can't catch fatal errors for some reason we need to reflect this in the documentation. Looking at the code I don't see any real reason not to be able to catch fatal errors.