send fatal errors
This commit is contained in:
		
				
					committed by
					
						
						Steffen Schröder
					
				
			
			
				
	
			
			
			
						parent
						
							d7c26d04ae
						
					
				
				
					commit
					859c57e111
				
			@@ -5,6 +5,7 @@
 | 
			
		||||
define('LOG_WRITE_CURRENT_FILE', 'ManiaControl.log'); // Write current log to extra file in base dir
 | 
			
		||||
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
 | 
			
		||||
define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder
 | 
			
		||||
define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_USER_ERROR);
 | 
			
		||||
 | 
			
		||||
// Define base dir
 | 
			
		||||
define('ManiaControlDir', __DIR__);
 | 
			
		||||
 
 | 
			
		||||
@@ -57,6 +57,8 @@ class ErrorHandler {
 | 
			
		||||
 | 
			
		||||
		if (!json_decode($success)) {
 | 
			
		||||
			logMessage("Exception-Report failed");
 | 
			
		||||
		} else {
 | 
			
		||||
			logMessage("Exception successfully reported!");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		exit();
 | 
			
		||||
@@ -101,11 +103,13 @@ class ErrorHandler {
 | 
			
		||||
			$success = FileUtil::loadFile($url);
 | 
			
		||||
 | 
			
		||||
			if (!json_decode($success)) {
 | 
			
		||||
				logMessage("Error-Report failed");
 | 
			
		||||
				logMessage("Error-Report failed!");
 | 
			
		||||
			} else {
 | 
			
		||||
				logMessage("Error successfully reported!");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($errorNumber == E_ERROR || $errorNumber == E_USER_ERROR) {
 | 
			
		||||
		if ($errorNumber == E_ERROR || $errorNumber == E_USER_ERROR || $errorNumber == E_FATAL) {
 | 
			
		||||
			logMessage('Stopping execution...');
 | 
			
		||||
			exit();
 | 
			
		||||
		}
 | 
			
		||||
@@ -128,6 +132,15 @@ class ErrorHandler {
 | 
			
		||||
		if ($errorLevel == E_ERROR) {
 | 
			
		||||
			return '[PHP ERROR]';
 | 
			
		||||
		}
 | 
			
		||||
		if ($errorLevel == E_CORE_ERROR) {
 | 
			
		||||
			return '[PHP CORE ERROR]';
 | 
			
		||||
		}
 | 
			
		||||
		if ($errorLevel == E_COMPILE_ERROR) {
 | 
			
		||||
			return '[PHP COMPILE ERROR]';
 | 
			
		||||
		}
 | 
			
		||||
		if ($errorLevel == E_RECOVERABLE_ERROR) {
 | 
			
		||||
			return '[PHP RECOVERABLE ERROR]';
 | 
			
		||||
		}
 | 
			
		||||
		if ($errorLevel == E_USER_NOTICE) {
 | 
			
		||||
			return '[ManiaControl NOTICE]';
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -223,6 +223,12 @@ class ManiaControl implements CommandListener {
 | 
			
		||||
		// Close the client connection
 | 
			
		||||
		$this->client->delete($this->server->ip, $this->server->port);
 | 
			
		||||
 | 
			
		||||
		//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->log('Quitting ManiaControl!');
 | 
			
		||||
		exit();
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user