As noted below, it's important to realize that unless caught, any Exception thrown will halt the script. So converting EVERY notice, warning, or error to an ErrorException will halt your script when something harmlesss like E_USER_NOTICE is triggered.
It seems to me the best use of the ErrorException class is something like this:
<?php
function custom_error_handler($number, $string, $file, $line, $context)
{
$error_is_enabled = (bool)($number & ini_get('error_reporting') );
if( in_array($number, array(E_USER_ERROR, E_RECOVERABLE_ERROR)) && $error_is_enabled ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
else if( $error_is_enabled ) {
error_log( $string, 0 );
return false; }
}
?>
Setting this function as the error handler will result in ErrorExceptions only being thrown for E_USER_ERROR and E_RECOVERABLE_ERROR, while other enabled error types will simply get error_log()'ed.
It's worth noting again that no matter what you do, "E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT" will never reach your custom error handler, and therefore will not be converted into ErrorExceptions. Plan accordingly.