Improved error printing in dev site

This commit is contained in:
Alex Cabal 2022-07-06 16:47:24 -05:00
parent 96f2da708a
commit f66f6e3287
2 changed files with 12 additions and 11 deletions

View file

@ -11,7 +11,8 @@ mb_http_output('UTF-8');
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
// Custom error handler to output more details about the specific Apache request that caused an exception. // Custom error handler to output more details about the specific Apache request that caused an exception.
set_exception_handler(function(Throwable $ex): void{ if(SITE_STATUS == SITE_STATUS_LIVE){
set_exception_handler(function(Throwable $ex): void{
$errorString = "----------------------------------------\n"; $errorString = "----------------------------------------\n";
$errorString .= trim(vds(array_intersect_key($_SERVER, ['REQUEST_URI' => '', 'QUERY_STRING' => '', 'REQUEST_METHOD' => '', 'REDIRECT_QUERY_STRING' => '', 'REDIRECT_URL' => '', 'SCRIPT_FILENAME' => '', 'REMOTE_ADDR' => '', 'HTTP_COOKIE' => '', 'HTTP_USER_AGENT' => '', 'SCRIPT_URI' => '']))); $errorString .= trim(vds(array_intersect_key($_SERVER, ['REQUEST_URI' => '', 'QUERY_STRING' => '', 'REQUEST_METHOD' => '', 'REDIRECT_QUERY_STRING' => '', 'REDIRECT_URL' => '', 'SCRIPT_FILENAME' => '', 'REMOTE_ADDR' => '', 'HTTP_COOKIE' => '', 'HTTP_USER_AGENT' => '', 'SCRIPT_URI' => ''])));
@ -23,4 +24,5 @@ set_exception_handler(function(Throwable $ex): void{
error_log($errorString); error_log($errorString);
throw $ex; // Send the exception back to PHP for its usual logging routine. throw $ex; // Send the exception back to PHP for its usual logging routine.
}); });
}

View file

@ -139,7 +139,6 @@ class DbConnection{
else{ else{
$done = true; $done = true;
if(SITE_STATUS == SITE_STATUS_DEV){ if(SITE_STATUS == SITE_STATUS_DEV){
print($sql);
throw($ex); throw($ex);
} }
else{ else{