mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-26 02:44:29 +00:00
We should error 500 when we have an exception that isn't caught.
This commit is contained in:
parent
0c582b9147
commit
47363b4f41
@ -18,7 +18,10 @@ unset($session); unset($request); unset($dbconn); unset($_awl_dbconn); unset($in
|
|||||||
// An ultra-simple exception handler to catch errors that occur
|
// An ultra-simple exception handler to catch errors that occur
|
||||||
// before we get a more functional exception handler in place...
|
// before we get a more functional exception handler in place...
|
||||||
function early_exception_handler($e) {
|
function early_exception_handler($e) {
|
||||||
if ( !headers_sent() ) header("Content-type: text/plain"); else echo "<pre>\n";
|
if ( !headers_sent() ) {
|
||||||
|
header("Content-type: text/plain"); else echo "<pre>\n";
|
||||||
|
header( sprintf("HTTP/1.1 %d %s", 500, getStatusMessage(500)) );
|
||||||
|
}
|
||||||
while ( ob_get_level() > 0 ) ob_end_flush();
|
while ( ob_get_level() > 0 ) ob_end_flush();
|
||||||
echo "Exception [".$e->getCode()."] ".$e->getmessage()."\n";
|
echo "Exception [".$e->getCode()."] ".$e->getmessage()."\n";
|
||||||
echo "At line ", $e->getLine(), " of ", $e->getFile(), "\n";
|
echo "At line ", $e->getLine(), " of ", $e->getFile(), "\n";
|
||||||
@ -28,6 +31,7 @@ function early_exception_handler($e) {
|
|||||||
foreach( $trace AS $k => $v ) {
|
foreach( $trace AS $k => $v ) {
|
||||||
printf( "%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']:'') );
|
printf( "%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');
|
set_exception_handler('early_exception_handler');
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,10 @@ unset($session); unset($request); unset($dbconn); unset($_awl_dbconn); unset($in
|
|||||||
// An ultra-simple exception handler to catch errors that occur
|
// An ultra-simple exception handler to catch errors that occur
|
||||||
// before we get a more functional exception handler in place...
|
// before we get a more functional exception handler in place...
|
||||||
function early_exception_handler($e) {
|
function early_exception_handler($e) {
|
||||||
if ( !headers_sent() ) header("Content-type: text/plain"); else echo "<pre>\n";
|
if ( !headers_sent() ) {
|
||||||
|
header("Content-type: text/plain"); else echo "<pre>\n";
|
||||||
|
header( sprintf("HTTP/1.1 %d %s", 500, getStatusMessage(500)) );
|
||||||
|
}
|
||||||
while ( ob_get_level() > 0 ) ob_end_flush();
|
while ( ob_get_level() > 0 ) ob_end_flush();
|
||||||
echo "Exception [".$e->getCode()."] ".$e->getmessage()."\n";
|
echo "Exception [".$e->getCode()."] ".$e->getmessage()."\n";
|
||||||
echo "At line ", $e->getLine(), " of ", $e->getFile(), "\n";
|
echo "At line ", $e->getLine(), " of ", $e->getFile(), "\n";
|
||||||
@ -28,6 +31,7 @@ function early_exception_handler($e) {
|
|||||||
foreach( $trace AS $k => $v ) {
|
foreach( $trace AS $k => $v ) {
|
||||||
printf( "%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']:'') );
|
printf( "%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');
|
set_exception_handler('early_exception_handler');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user