improved error handler method names

This commit is contained in:
Steffen Schröder 2014-05-03 22:21:57 +02:00
parent 4f1d560d0b
commit 334892c287
2 changed files with 11 additions and 16 deletions

View File

@ -30,8 +30,8 @@ class ErrorHandler {
*/ */
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
set_error_handler(array(&$this, 'errorHandler'), -1); set_error_handler(array(&$this, 'handleError'), -1);
set_exception_handler(array(&$this, 'exceptionHandler')); set_exception_handler(array(&$this, 'handleException'));
} }
/** /**
@ -47,7 +47,7 @@ class ErrorHandler {
* @param \Exception $ex * @param \Exception $ex
* @param bool $shutdown * @param bool $shutdown
*/ */
public function exceptionHandler(\Exception $ex, $shutdown = true) { public function handleException(\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;
@ -116,24 +116,19 @@ class ErrorHandler {
* @param $message * @param $message
*/ */
public function triggerDebugNotice($message) { public function triggerDebugNotice($message) {
$this->errorHandler(self::MC_DEBUG_NOTICE, $message); $this->handleError(self::MC_DEBUG_NOTICE, $message);
} }
/** /**
* Error Handler * Error Handler
* *
* @param $errorNumber * @param int $errorNumber
* @param $errorString * @param string $errorString
* @param $errorFile * @param string $errorFile
* @param $errorLine * @param int $errorLine
* @return bool * @return bool
*/ */
public function errorHandler($errorNumber, $errorString, $errorFile = null, $errorLine = -1) { public function handleError($errorNumber, $errorString, $errorFile = null, $errorLine = -1) {
if (error_reporting() === 0) {
// Error suppressed
return false;
}
$userError = $this->isUserErrorNumber($errorNumber); $userError = $this->isUserErrorNumber($errorNumber);
// Log error // Log error

View File

@ -305,7 +305,7 @@ class ManiaControl implements CommandListener, TimerListener {
// Check and Trigger Fatal Errors // Check and Trigger Fatal Errors
$error = error_get_last(); $error = error_get_last();
if ($error && ($error['type'] & E_FATAL)) { if ($error && ($error['type'] & E_FATAL)) {
$this->errorHandler->errorHandler($error['type'], $error['message'], $error['file'], $error['line']); $this->errorHandler->handleError($error['type'], $error['message'], $error['file'], $error['line']);
} }
// Disable Garbage Collector // Disable Garbage Collector
@ -376,7 +376,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->exceptionHandler($e, false); $this->errorHandler->handleException($e, false);
} }
$this->quit($e->getMessage()); $this->quit($e->getMessage());
} }