diff --git a/public_html/includes/class/class.LSerror.php b/public_html/includes/class/class.LSerror.php index 0da9a1e9..8c41d1a6 100644 --- a/public_html/includes/class/class.LSerror.php +++ b/public_html/includes/class/class.LSerror.php @@ -171,11 +171,57 @@ class LSerror { } return; } + + /** + * PHP error handler (see set_error_handler() function doc) + **/ + public function errorHandler($errno, $errstr, $errfile, $errline) { + self :: addErrorCode(-2,"Error ".self :: convertPHPErrorNo($errno)." occured in file $errfile (line : $errline) : $errstr"); + if ( E_RECOVERABLE_ERROR===$errno ) { + throw new ErrorException($errstr, $errno, 0, $errfile, $errline); + } + return False; + } + + /** + * Convert PHP error number to string + * + * @param[in] $errno int Error number + * + * @retval string Corresponding error name + **/ + public function convertPHPErrorNo($errno) { + $error_levels=array ( + 1 => "ERROR", + 2 => "WARNING", + 4 => "PARSE", + 8 => "NOTICE", + 16 => "CORE_ERROR", + 32 => "CORE_WARNING", + 64 => "COMPILE_ERROR", + 128 => "COMPILE_WARNING", + 256 => "USER_ERROR", + 512 => "USER_WARNING", + 1024 => "USER_NOTICE", + 2048 => "STRICT", + 4096 => "RECOVERABLE_ERROR", + 8192 => "DEPRECATED", + 16384 => "USER_DEPRECATED", + 32767 => "ALL", + ); + if (isset($error_levels[$errno])) { + return $error_levels[$errno]; + } + else { + return "UNKNOWN_ERROR"; + } + } } /* * Error Codes */ -LSerror :: defineError(-1,_("Unknown error!")); +LSerror :: defineError(-1,_("Unknown error : %{error}")); +LSerror :: defineError(-2,_("PHP error : %{error}")); ?> diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 2e0fe94f..a0bdae06 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -191,6 +191,7 @@ class LSsession { if(!self :: loadLSclass('LSerror')) { return; } + set_error_handler(array('LSerror','errorHandler'),E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING); self :: defineLSerrors(); return true; }