Tuesday, June 2, 2009

PHP: try catch not working/exception is not catched

If the catch block in your code is not executed and you are getting error/warning message in the browser, it is an issue with the behavior of PHP. In php some errors/warnings are not exceptions.

You could convert all errors to exceptions by using the following in your code.

set_error_handler(create_function('$p1, $p2, $p3, $p4', 'throw new ErrorException($p2, 0, $p1, $p3, $p4);'), E_ALL);

No comments:

Post a Comment