I have a static class function 'DB::query' which handles most SQL queries. And now I've found a fatal error in the error log concerning an uncaught exception pointing to this file. However, for some reason I lack the much needed backtrace information.
This is part of a static function
$result = mysql_query($sql, self::$link);
if (!$result) {
/* Line 41 */ $e = new ErrorHandler();
$e->addError("DB", array("sqlfailed", mysql_error(self::$link)));
# Add to sql_error_log
$logtext = date("H.i Y-m-d").": $sql\n" . mysql_error(self::$link) . "\n";
if ($GLOBALS['connectionpath'] == 'dev.somewhere.com')
echo $logtext;
else
file_put_contents($GLOBALS['serverpath'] . '/sql_error_log', $logtext, FILE_APPEND);
throw $e;
}
This is used in a lot of files, and somewhere it's not wrapped in a try/catch statement, which not surprisingly shows up in the php_error_log as:
PHP Fatal error: Uncaught exception 'ErrorHandler' in /data/www/phpclasses/DB.php:41
However, if I intentionally create this error in our development or test environment, I also get the information needed to track down and pinpoint the problem:
Uncaught exception 'ErrorHandler' in /path/DB.php:41 Stack trace: #0 /path/error_test.php(6): DB::query() #1 /path/error_test.php(10): Test->__construct() #2 {main} thrown in /path/DB.php on line 41
So, what might cause the lack of a stack trace?