getTrace() as $t) {
$trace[]=''.$t['function'].'('.htmlentities(implode(', ', $t['args'])).') at '.$t['file'].' line '.$t['line'].'
';
}
$trace=implode(' from
', $trace);
$death.=print_error('Uncaught '.get_class($e).': '.$e->getMessage(), 'Thrown at:
'.$trace);
}
set_exception_handler('exception_handler');
// Directly copied from PHP Manual -> Language Reference -> Predefined Exceptions -> ErrorException
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
if ((error_reporting() & $errno) == 0) { // Don't report errors that aren't supposed to be reported
return;
}
global $death;
$errtypes=array(
E_ERROR => 'Fatal Error',
E_WARNING => 'Warning',
E_PARSE => 'Parse Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Fatal Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Fatal Compile-Time Error',
E_COMPILE_WARNING => 'Compile-Time Warning',
E_USER_ERROR => 'Fatal User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Strict Message',
E_RECOVERABLE_ERROR => 'Recoverable Fatal Error'/*,
// PHP 5.3.0:
E_DEPRECATED => 'Deprecation Notice',
E_USER_DEPRECATED => 'User Deprecation Notice'
*/
);
if (isset($errtypes[$errno])) {
$type=$errtypes[$errno];
} else {
$type='Unknown Error';
}
$trace='';
foreach (debug_backtrace() as $t) {
if (!isset($first)) {
$first=false;
continue;
}
if (isset($t['args'])) {
foreach ($t['args'] as $i => $arg) {
if (!is_scalar($arg)) {
$t['args'][$i]=var_export($arg, true);
}
}
}
$trace.='from '.(isset($t['function'])?(isset($t['class'])?$t['class'].$t['type']:'').$t['function'].''.(isset($t['args'])?'('.htmlentities(implode(', ', $t['args'])).')':''):(isset($t['args'])?'Included file(s) '.implode(', ', $t['args']):'')).(isset($t['file'])?' at '.$t['file'].''.(isset($t['line'])?' line '.$t['line'].'':''):'').'
';
}
$death.=print_error($type, $errstr.'
'.$trace);
}
set_error_handler("exception_error_handler");
?>