mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 08:19:05 +01:00
LSerror : Add PHP error handler
This commit is contained in:
parent
1e37b2f870
commit
bb09c81243
2 changed files with 48 additions and 1 deletions
|
@ -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}"));
|
||||
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue