I was wondering if it’s considered a bad practice to globally convert all PHP Errors to Exceptions. Something like the following would be used:
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
return false;
}
I suppose the assumption is that you can just start using “try/catch” around certain pieces of code that would normally throw Errors.
If it’s not a case of Good/Bad, what are some of the Gotchas that could arise from this practice?
Unfortunately, this won’t work on fatal/parse/etc. errors…
Don’t remember exactly, but I’ve tried this and in some cases got a message like “can’t throw exception without workaround…” but I can’t remember the conditions to get this result. But now I use this way and completely satisfied.