error reports: backtrace split from message
This commit is contained in:
parent
57375a6e8b
commit
4d5280ce8f
@ -38,15 +38,16 @@ class ErrorHandler {
|
||||
* @param \Exception $ex
|
||||
*/
|
||||
public function exceptionHandler(\Exception $ex) {
|
||||
$message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}" . PHP_EOL;
|
||||
$message .= "Class: " . get_class($ex) . PHP_EOL;
|
||||
$message .= "Trace: {$ex->getTraceAsString()}" . PHP_EOL;
|
||||
logMessage($message);
|
||||
$message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}";
|
||||
$traceMessage = 'Class: ' . get_class($ex) . PHP_EOL;
|
||||
$traceMessage .= 'Trace:' . PHP_EOL . $ex->getTraceAsString();
|
||||
logMessage($message . PHP_EOL . $traceMessage);
|
||||
|
||||
if ($this->reportErrors) {
|
||||
$error = array();
|
||||
$error["Type"] = "Exception";
|
||||
$error["Message"] = $message;
|
||||
$error["Backtrace"] = $traceMessage;
|
||||
$error['OperatingSystem'] = php_uname();
|
||||
$error['PHPVersion'] = phpversion();
|
||||
|
||||
@ -102,13 +103,15 @@ class ErrorHandler {
|
||||
|
||||
// Log error
|
||||
$errorTag = $this->getErrorTag($errorNumber);
|
||||
$message = "{$errorTag}: {$errorString} in File '{$errorFile}' on Line {$errorLine}!";
|
||||
logMessage($message);
|
||||
$message = $errorTag . ': ' . $errorString;
|
||||
$traceMessage = $this->parseBackTrace(debug_backtrace());
|
||||
logMessage($message . PHP_EOL . $traceMessage);
|
||||
|
||||
if ($this->reportErrors && $errorNumber != E_USER_ERROR && $errorNumber != E_USER_WARNING && $errorNumber != E_USER_NOTICE) {
|
||||
$error = array();
|
||||
$error["Type"] = "Error";
|
||||
$error["Message"] = $message;
|
||||
$error["Backtrace"] = $traceMessage;
|
||||
$error['OperatingSystem'] = php_uname();
|
||||
$error['PHPVersion'] = phpversion();
|
||||
|
||||
@ -200,4 +203,36 @@ class ErrorHandler {
|
||||
}
|
||||
return "[PHP {$errorLevel}]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the Debug Backtrace into a String for the Error Report
|
||||
*
|
||||
* return string
|
||||
*/
|
||||
private function parseBackTrace(array $backtrace) {
|
||||
$traceString = 'Trace:';
|
||||
$stepCount = 0;
|
||||
foreach ($backtrace as $traceStep) {
|
||||
$traceString .= PHP_EOL . '#' . $stepCount . ': ';
|
||||
if (isset($traceStep['class'])) {
|
||||
$traceString .= $traceStep['class'];
|
||||
}
|
||||
if (isset($traceStep['type'])) {
|
||||
$traceString .= $traceStep['type'];
|
||||
}
|
||||
if (isset($traceStep['function'])) {
|
||||
$traceString .= $traceStep['function'];
|
||||
}
|
||||
if (isset($traceStep['file'])) {
|
||||
$traceString .= ' in File ';
|
||||
$traceString .= $traceStep['file'];
|
||||
}
|
||||
if (isset($traceStep['line'])) {
|
||||
$traceString .= ' on Line ';
|
||||
$traceString .= $traceStep['line'];
|
||||
}
|
||||
$stepCount++;
|
||||
}
|
||||
return $traceString;
|
||||
}
|
||||
}
|
@ -127,7 +127,6 @@ class ManiaControl implements CommandListener, TimerListener {
|
||||
$this->commandManager->registerCommandListener('shutdown', $this, 'command_Shutdown', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a message to console and log
|
||||
*
|
||||
|
@ -214,8 +214,8 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
public function getQueuedMapsRanking() {
|
||||
$i = 1;
|
||||
$queuedMaps = array();
|
||||
foreach($this->queuedMaps as $map) {
|
||||
$map = $map[1];
|
||||
foreach($this->queuedMaps as $queuedMap) {
|
||||
$map = $queuedMap[1];
|
||||
$queuedMaps[$map->uid] = $i;
|
||||
$i++;
|
||||
}
|
||||
|
@ -844,7 +844,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the given xml rpc method and params
|
||||
* Encode the given xml rpc method and params
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
@ -856,7 +856,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles xml rpc fault
|
||||
* Handle xml rpc fault
|
||||
*
|
||||
* @param $fault
|
||||
* @param $method
|
||||
@ -865,10 +865,14 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
||||
trigger_error('XmlRpc Fault on ' . $method . ': ' . $fault['faultString'] . ' (' . $fault['faultCode'] . ')');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build Manialink
|
||||
*
|
||||
* @return \FML\ManiaLink
|
||||
*/
|
||||
private function buildManialink() {
|
||||
if (!$this->dedimaniaData->records) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
$records = $this->dedimaniaData->records;
|
||||
|
||||
|
@ -448,7 +448,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
$requester = null;
|
||||
// if the nextmap is not a queued map, get it from map info
|
||||
if ($queuedMap == null) {
|
||||
if (!$queuedMap) {
|
||||
$map = $this->maniaControl->client->getNextMapInfo();
|
||||
$name = Formatter::stripDirtyCodes($map->name);
|
||||
$author = $map->author;
|
||||
|
Loading…
Reference in New Issue
Block a user