improved connection exception reporting

This commit is contained in:
Steffen Schröder 2014-04-28 19:12:40 +02:00
parent 8a068a256d
commit 429702d2e6
2 changed files with 13 additions and 12 deletions

View File

@ -8,7 +8,7 @@ use ManiaControl\Callbacks\Callbacks;
/** /**
* Error and Exception Manager Class * Error and Exception Manager Class
* *
* @author steeffeen & kremsy * @author steeffeen & kremsy
* @copyright ManiaControl Copyright © 2014 ManiaControl Team * @copyright ManiaControl Copyright © 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
@ -45,10 +45,10 @@ class ErrorHandler {
/** /**
* ManiaControl ExceptionHandler * ManiaControl ExceptionHandler
* ManiaControl Shuts down after exception * ManiaControl Shuts down after exception
* *
* @param \Exception $ex * @param \Exception $ex
*/ */
public function exceptionHandler(\Exception $ex) { public function exceptionHandler(\Exception $ex, $shutdown = true) {
// Log exception // Log exception
$message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}"; $message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}";
$traceMessage = 'Class: ' . get_class($ex) . PHP_EOL; $traceMessage = 'Class: ' . get_class($ex) . PHP_EOL;
@ -93,15 +93,17 @@ class ErrorHandler {
} }
} }
if ($this->shouldRestart()) { if ($shutdown) {
$this->maniaControl->restart(); if ($this->shouldRestart()) {
$this->maniaControl->restart();
}
exit();
} }
exit();
} }
/** /**
* Error Handler * Error Handler
* *
* @param $errorNumber * @param $errorNumber
* @param $errorString * @param $errorString
* @param $errorFile * @param $errorFile
@ -169,7 +171,7 @@ class ErrorHandler {
/** /**
* Triggers a Debug Notice to the ManiaControl Website * Triggers a Debug Notice to the ManiaControl Website
* *
* @param $message * @param $message
*/ */
public function triggerDebugNotice($message) { public function triggerDebugNotice($message) {
@ -178,7 +180,7 @@ class ErrorHandler {
/** /**
* Get the prefix for the given error level * Get the prefix for the given error level
* *
* @param int $errorLevel * @param int $errorLevel
* @return string * @return string
*/ */
@ -218,7 +220,7 @@ class ErrorHandler {
/** /**
* Test if ManiaControl should restart automatically * Test if ManiaControl should restart automatically
* *
* @return bool * @return bool
*/ */
private function shouldRestart() { private function shouldRestart() {
@ -231,7 +233,6 @@ class ErrorHandler {
/** /**
* Parse the Debug Backtrace into a String for the Error Report * Parse the Debug Backtrace into a String for the Error Report
*
* return string * return string
*/ */
private function parseBackTrace(array $backtrace) { private function parseBackTrace(array $backtrace) {

View File

@ -353,7 +353,7 @@ class ManiaControl implements CommandListener, TimerListener {
$this->log("Connection interrupted!"); $this->log("Connection interrupted!");
// TODO remove // TODO remove
if ($this->errorHandler) { if ($this->errorHandler) {
$this->errorHandler->triggerDebugNotice("Fatal Exception: " . $e->getMessage() . " Trace: " . $e->getTraceAsString()); $this->errorHandler->exceptionHandler($e, false);
} }
$this->quit($e->getMessage()); $this->quit($e->getMessage());
} }