improved error report

This commit is contained in:
Steffen Schröder 2014-06-15 03:37:07 +02:00
parent f6ac379dc0
commit 5e375c0c13

View File

@ -81,33 +81,45 @@ class ErrorHandler {
} }
// Build log message // Build log message
$errorTag = $this->getErrorTag($errorNumber); $errorTag = $this->getErrorTag($errorNumber);
$userError = $this->isUserErrorNumber($errorNumber); $userError = $this->isUserErrorNumber($errorNumber);
$traceSourceClass = null;
$message = $errorTag . ': ' . $errorString; $traceString = null;
$fileLine = $errorFile . ': ' . $errorLine; $sourceClass = null;
$traceString = $this->parseBackTrace(array_slice(debug_backtrace(), 1), $traceSourceClass); $traceSourceClass = null;
$sourceClass = $this->getSourceClass($errorFile); $fileLine = null;
if (!$sourceClass) {
$message = $errorTag . ': ' . $errorString;
if (!$onShutdown) {
$traceString = $this->parseBackTrace(array_slice(debug_backtrace(), 1), $traceSourceClass);
}
if ($errorFile) {
$fileLine = $errorFile . ': ' . $errorLine;
$sourceClass = $this->getSourceClass($errorFile);
}
if (!$sourceClass && $traceSourceClass) {
$sourceClass = $traceSourceClass; $sourceClass = $traceSourceClass;
} }
$logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine; $logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine;
if (!$userError && !$onShutdown) { if (!$userError && $traceString) {
$logMessage .= PHP_EOL . 'Trace: ' . PHP_EOL . $traceString; $logMessage .= PHP_EOL . 'Trace: ' . PHP_EOL . $traceString;
} }
$this->maniaControl->log($logMessage); $this->maniaControl->log($logMessage);
if (!DEV_MODE && !$userError && !$suppressed) { if (!DEV_MODE && !$userError && !$suppressed) {
// Report error // Report error
$report = array(); $report = array();
$report['Type'] = 'Error'; $report['Type'] = 'Error';
$report['Message'] = $message; $report['Message'] = $message;
$report['FileLine'] = $fileLine; if ($fileLine) {
$report['SourceClass'] = $sourceClass; $report['FileLine'] = $fileLine;
$report['PluginId'] = PluginManager::getPluginId($sourceClass); }
if (!$onShutdown) { if ($sourceClass) {
$report['SourceClass'] = $sourceClass;
$report['PluginId'] = PluginManager::getPluginId($sourceClass);
}
if ($traceString) {
$report['Backtrace'] = $traceString; $report['Backtrace'] = $traceString;
} }
$report['OperatingSystem'] = php_uname(); $report['OperatingSystem'] = php_uname();