Adam Zey wrote: > Christopher J. Bottaro wrote: >> Hello, >> How can I trap a fatal error (like calling a non existant method, >> requiring >> a non existant file, etc) and go to a user defined error handler? I >> tried set_error_handler(), but it seems to skip over the errors I care >> about. >> >> Thanks for the help. > > It is always safer to handle errors before they happen by checking that > you're in a good state before you try to do something. > > For example, nonexistent files can be handled by file_exists(). > Undefined functions can be checked with function_exists(). > > Regards, Adam Zey. Well, I know that. Sometimes unexpected errors happen. We write hundreds of lines of code a day. Typos happen, I forget some includes, I type $d->appendCild() instead of $d->appendChild(). It's all a part of the development process. Our application makes extensive use of AJAX and JSON. Sometimes we make an AJAX request and expect a JSON object in return, but instead a fatal error happens (DOMDocument::appendChid() does not exist), well now we get a JSON error because the response headers were messed up by the fatal error. That JSON error is useless. We would rather see the real error as PHP would have reported it on a simple webpage or command line. Basically, we just want to trap all errors and reraise them as exceptions so that our app's default exception handler can report them. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php