Class ErrorHandler
Simple error and exception handler. – wraps the error to an ErrorException instance according to error reporting level – when running the PHP CLI, reports errors/exceptions to STDERR (even fatal error) and uses exception code as exit status – allows to deactivate '@' operator – catches fatal error – accepts callback to be executed at the end of the internal shutdown function – accepts callback to display an apology when errors are hidden – allows to ignore errors on some paths, useful with old libraries and deprecated code…
Copyright (c) 2012 Geoffroy Aubry <geoffroy.aubry@free.fr> Licensed under the GNU Lesser General Public License v3 (LGPL version 3).
Copyright: 2012 Geoffroy Aubry <geoffroy.aubry@free.fr>
License: http://www.gnu.org/licenses/lgpl.html
Located at errorhandler/src/GAubry/ErrorHandler/ErrorHandler.php
public
|
|
public
|
#
addExcludedPath( string $sPath )
Allows to ignore errors on some paths, useful with old libraries and deprecated code… Trailing slash is optional. |
public
|
#
setCallbackGenericDisplay( callable $cbGenericDisplay )
Set callback to display an apology when errors are hidden. Current \Exception will be provided in parameter. |
public
|
#
setCallbackAdditionalShutdownFct( callable $cbAddShutdownFct )
Set callback to be executed at the end of the internal shutdown function. |
public
boolean
|
#
internalErrorHandler( integer $iErrNo, string $sErrStr, string $sErrFile, integer $iErrLine )
Customized error handler function: throws an Exception with the message error if @ operator not used and error source is not in excluded paths. |
public
|
|
public
|
|
public
|
|
public
|
public static
array
|
$aErrorTypes | array(
E_ERROR => 'ERROR',
E_WARNING => 'WARNING',
E_PARSE => 'PARSING ERROR',
E_NOTICE => 'NOTICE',
E_CORE_ERROR => 'CORE ERROR',
E_CORE_WARNING => 'CORE WARNING',
E_COMPILE_ERROR => 'COMPILE ERROR',
E_COMPILE_WARNING => 'COMPILE WARNING',
E_USER_ERROR => 'USER ERROR',
E_USER_WARNING => 'USER WARNING',
E_USER_NOTICE => 'USER NOTICE',
E_STRICT => 'STRICT NOTICE',
E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR'
) |
#
Error codes. |
private
boolean
|
$bIsRunningFromCLI |
|
#
CLI ? |
private
array
|
$aExcludedPaths |
|
#
Errors will be ignored on these paths. Useful with old libraries and deprecated code. |
private
callable
|
$callbackGenericDisplay |
|
#
Callback to display an apology when errors are hidden. |
private
callable
|
$callbackAdditionalShutdownFct |
|
#
Callback to be executed at the end of the internal shutdown function |
private static
array
|
$aDefaultConfig | array(
'display_errors' => true,
'error_log_path' => '',
'error_reporting_level' => -1,
'auth_error_suppr_op' => false,
'default_error_code' => 1,
'error_div_class' => 'error'
) |
#
Default config. |
private
array
|
$aConfig |
|
#
Configuration. |