From f66f6e3287d3dd91ad2440dde57313f179cb6d21 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Wed, 6 Jul 2022 16:47:24 -0500 Subject: [PATCH] Improved error printing in dev site --- lib/Core.php | 22 ++++++++++++---------- lib/DbConnection.php | 1 - 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/Core.php b/lib/Core.php index f83331d1..005767e1 100644 --- a/lib/Core.php +++ b/lib/Core.php @@ -11,16 +11,18 @@ mb_http_output('UTF-8'); date_default_timezone_set('UTC'); // Custom error handler to output more details about the specific Apache request that caused an exception. -set_exception_handler(function(Throwable $ex): void{ - $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' => '']))); +if(SITE_STATUS == SITE_STATUS_LIVE){ + set_exception_handler(function(Throwable $ex): void{ + $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' => '']))); - if(sizeof($_POST) > 0){ - $errorString .= "POST DATA:\n"; - $errorString .= vds($_POST); - } + if(sizeof($_POST) > 0){ + $errorString .= "POST DATA:\n"; + $errorString .= vds($_POST); + } - 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. + }); +} diff --git a/lib/DbConnection.php b/lib/DbConnection.php index 26c96b5a..bcf1fe4e 100644 --- a/lib/DbConnection.php +++ b/lib/DbConnection.php @@ -139,7 +139,6 @@ class DbConnection{ else{ $done = true; if(SITE_STATUS == SITE_STATUS_DEV){ - print($sql); throw($ex); } else{