Enhance the exception handler to display a forward trace

This commit is contained in:
Andrew McMillan 2010-03-13 00:00:47 +13:00
parent b4e2a14552
commit aaebf97bee
2 changed files with 14 additions and 4 deletions

View File

@ -14,8 +14,13 @@ unset($session); unset($request); unset($dbconn); unset($_awl_dbconn); unset($in
// An ultra-simple exception handler to catch errors that occur
// before we get a more functional exception handler in place...
function early_exception_handler($exception) {
echo "Uncaught early exception: ", $exception->getMessage(), "\n";
function early_exception_handler($e) {
echo "Uncaught early exception: ", $e->getMessage(), "\nAt line ", $e->getLine(), " of ", $e->getFile(), "\n";
$trace = array_reverse($e->getTrace());
foreach( $trace AS $k => $v ) {
printf( "=====================================================\n%s[%d] %s%s%s()\n", $v['file'], $v['line'], (isset($v['class'])?$v['class']:''), (isset($v['type'])?$v['type']:''), (isset($v['function'])?$v['function']:'') );
}
}
set_exception_handler('early_exception_handler');

View File

@ -14,8 +14,13 @@ unset($session); unset($request); unset($dbconn); unset($_awl_dbconn); unset($in
// An ultra-simple exception handler to catch errors that occur
// before we get a more functional exception handler in place...
function early_exception_handler($exception) {
echo "Uncaught early exception: ", $exception->getMessage(), "\n";
function early_exception_handler($e) {
echo "Uncaught early exception: ", $e->getMessage(), "\nAt line ", $e->getLine(), " of ", $e->getFile(), "\n";
$trace = array_reverse($e->getTrace());
foreach( $trace AS $k => $v ) {
printf( "=====================================================\n%s[%d] %s%s%s()\n", $v['file'], $v['line'], (isset($v['class'])?$v['class']:''), (isset($v['type'])?$v['type']:''), (isset($v['function'])?$v['function']:'') );
}
}
set_exception_handler('early_exception_handler');