From b2a37779ae9f21a4b735e9c6e53b7a62bb1381dc Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 30 Sep 2011 11:33:35 +0200 Subject: [PATCH] Added support for additional debug output if a critical error occurs (For example during a database operation) --- src/include/functions_common.php | 18 ++++++++++++++++-- src/include/functions_db.php | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/include/functions_common.php b/src/include/functions_common.php index c4fd7e4..6217651 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -1034,7 +1034,8 @@ function DieWithErrorMsg( $szerrmsg ) } else if ( $RUNMODE == RUNMODE_WEBSERVER ) { - print( + // Print main error! + print ( "Adiscon LogAnalyzer :: Critical Error occured" . "

" . "". @@ -1044,7 +1045,20 @@ function DieWithErrorMsg( $szerrmsg ) "" . "
Errordetails:
" . $szerrmsg . - "

" . + "

"); + + // Print Detail error's if available + if ( isset($content['detailederror']) ) + { + print ("". + "" . + "
Additional Errordetails:
" . + $content['detailederror'] . + "

"); + } + + // End HTML Body + print( "" ); } diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 69406cb..9d63488 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -211,13 +211,14 @@ function DB_ReturnSimpleErrorMsg() function DB_PrintError($MyErrorMsg, $DieOrNot) { - global $n,$HTTP_COOKIE_VARS, $errdesc, $errno, $linesep; + global $content, $n,$HTTP_COOKIE_VARS, $errdesc, $errno, $linesep; $errdesc = mysql_error(); $errno = mysql_errno(); // Define global variable so we know an error has occured! - define('PHPLOGCON_INERROR', true); + if ( !defined('PHPLOGCON_INERROR') ) + define('PHPLOGCON_INERROR', true); $errormsg="Database error: $MyErrorMsg $linesep"; $errormsg.="mysql error: $errdesc $linesep"; @@ -229,7 +230,20 @@ function DB_PrintError($MyErrorMsg, $DieOrNot) if ($DieOrNot == true) DieWithErrorMsg( "$linesep" . $errormsg ); else + { OutputDebugMessage("DB_PrintError: $errormsg", DEBUG_ERROR); + + if ( !isset($content['detailederror']) ) + { + $content['detailederror_code'] = ERROR_DB_QUERYFAILED; + $content['detailederror'] = GetErrorMessage(ERROR_DB_QUERYFAILED); + } + else + $content['detailederror'] .= "

" . GetErrorMessage(ERROR_DB_QUERYFAILED); + + // Append SQL Detail Error + $content['detailederror'] .= "

" . $errormsg; + } } function DB_RemoveParserSpecialBadChars($myString)