From 334892c2875bfa651ceb6d0829b011d3aff446d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sat, 3 May 2014 22:21:57 +0200 Subject: [PATCH] improved error handler method names --- application/core/ErrorHandler.php | 23 +++++++++-------------- application/core/ManiaControl.php | 4 ++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index e6596e70..62b2d13d 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -30,8 +30,8 @@ class ErrorHandler { */ public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - set_error_handler(array(&$this, 'errorHandler'), -1); - set_exception_handler(array(&$this, 'exceptionHandler')); + set_error_handler(array(&$this, 'handleError'), -1); + set_exception_handler(array(&$this, 'handleException')); } /** @@ -47,7 +47,7 @@ class ErrorHandler { * @param \Exception $ex * @param bool $shutdown */ - public function exceptionHandler(\Exception $ex, $shutdown = true) { + public function handleException(\Exception $ex, $shutdown = true) { // Log exception $message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}"; $traceMessage = 'Class: ' . get_class($ex) . PHP_EOL; @@ -116,24 +116,19 @@ class ErrorHandler { * @param $message */ public function triggerDebugNotice($message) { - $this->errorHandler(self::MC_DEBUG_NOTICE, $message); + $this->handleError(self::MC_DEBUG_NOTICE, $message); } /** * Error Handler * - * @param $errorNumber - * @param $errorString - * @param $errorFile - * @param $errorLine + * @param int $errorNumber + * @param string $errorString + * @param string $errorFile + * @param int $errorLine * @return bool */ - public function errorHandler($errorNumber, $errorString, $errorFile = null, $errorLine = -1) { - if (error_reporting() === 0) { - // Error suppressed - return false; - } - + public function handleError($errorNumber, $errorString, $errorFile = null, $errorLine = -1) { $userError = $this->isUserErrorNumber($errorNumber); // Log error diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 56515f9e..4fe69c5c 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -305,7 +305,7 @@ class ManiaControl implements CommandListener, TimerListener { // Check and Trigger Fatal Errors $error = error_get_last(); 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 @@ -376,7 +376,7 @@ class ManiaControl implements CommandListener, TimerListener { $this->log("Connection interrupted!"); // TODO remove if ($this->errorHandler) { - $this->errorHandler->exceptionHandler($e, false); + $this->errorHandler->handleException($e, false); } $this->quit($e->getMessage()); }