Overview

Namespaces

  • GAubry
    • ErrorHandler
    • Helpers
    • Logger
    • Shell
  • Himedia
    • Padocc
      • DB
      • Minifier
      • Numbering
      • Properties
      • Task
        • Base
        • Extended
  • None
  • Psr
    • Log

Classes

  • ErrorHandler
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

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).

Namespace: GAubry\ErrorHandler
Copyright: 2012 Geoffroy Aubry <geoffroy.aubry@free.fr>
License: http://www.gnu.org/licenses/lgpl.html
Located at errorhandler/src/GAubry/ErrorHandler/ErrorHandler.php
Methods summary
public
# __construct( array $aConfig = array() )

Constructor.

Constructor.

Parameters

$aConfig
array
$aConfig see self::$aDefaultConfig
public
# addExcludedPath( string $sPath )

Allows to ignore errors on some paths, useful with old libraries and deprecated code… Trailing slash is optional.

Allows to ignore errors on some paths, useful with old libraries and deprecated code… Trailing slash is optional.

Parameters

$sPath
string
$sPath

See

GAubry\ErrorHandler\ErrorHandler::internalErrorHandler()
public
# setCallbackGenericDisplay( callable $cbGenericDisplay )

Set callback to display an apology when errors are hidden. Current \Exception will be provided in parameter.

Set callback to display an apology when errors are hidden. Current \Exception will be provided in parameter.

Parameters

$cbGenericDisplay
callable
$cbGenericDisplay
public
# setCallbackAdditionalShutdownFct( callable $cbAddShutdownFct )

Set callback to be executed at the end of the internal shutdown function.

Set callback to be executed at the end of the internal shutdown function.

Parameters

$cbAddShutdownFct
callable
$cbAddShutdownFct
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.

Customized error handler function: throws an Exception with the message error if @ operator not used and error source is not in excluded paths.

Parameters

$iErrNo
integer
$iErrNo level of the error raised.
$sErrStr
string
$sErrStr the error message.
$sErrFile
string
$sErrFile the filename that the error was raised in.
$iErrLine
integer
$iErrLine the line number the error was raised at.

Returns

boolean
true, then the normal error handler does not continue.

Throws

ErrorException
if $iErrNo is present in $iErrorReporting

See

GAubry\ErrorHandler\ErrorHandler::addExcludedPath()
public
# internalExceptionHandler( Exception $oException )

Exception handler.

Exception handler.

Parameters

$oException
Exception
$oException

SuppressWarnings(ExitExpression)

public
# displayDefaultApologies( )

Default callback to display an apology when errors are hidden.

Default callback to display an apology when errors are hidden.

public
# internalShutdownFunction( )

Registered shutdown function.

Registered shutdown function.

public
# log( mixed $mError )

According to context, logs specified error into STDERR, STDOUT or via error_log().

According to context, logs specified error into STDERR, STDOUT or via error_log().

Parameters

$mError
mixed
$mError Error to log. Can be string, array or object.
Properties summary
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.

Error codes.

See

GAubry\ErrorHandler\ErrorHandler::internalErrorHandler()
private boolean $bIsRunningFromCLI
#

CLI ?

CLI ?

private array $aExcludedPaths
#

Errors will be ignored on these paths. Useful with old libraries and deprecated code.

Errors will be ignored on these paths. Useful with old libraries and deprecated code.

See

GAubry\ErrorHandler\ErrorHandler::addExcludedPath()
private callable $callbackGenericDisplay
#

Callback to display an apology when errors are hidden.

Callback to display an apology when errors are hidden.

private callable $callbackAdditionalShutdownFct
#

Callback to be executed at the end of the internal shutdown function

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.
– 'display_errors' => (bool) Determines whether errors should be printed to the screen
as part of the output or if they should be hidden from the user.
– 'error_log_path' => (string) Name of the file where script errors should be logged.
– 'error_reporting_level' => (int) Error reporting level.
– 'auth_error_suppr_op' => (bool) Allows to deactivate '@' operator.
– 'default_error_code' => (int) Default error code for errors converted into exceptions
or for exceptions without code.
– 'error_div_class' => (string) CSS class for <DIV> tags surrounding errors displayed
in HTML context (non-CLI).

Default config. – 'display_errors' => (bool) Determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user. – 'error_log_path' => (string) Name of the file where script errors should be logged. – 'error_reporting_level' => (int) Error reporting level. – 'auth_error_suppr_op' => (bool) Allows to deactivate '@' operator. – 'default_error_code' => (int) Default error code for errors converted into exceptions or for exceptions without code. – 'error_div_class' => (string) CSS class for <DIV> tags surrounding errors displayed in HTML context (non-CLI).

private array $aConfig
#

Configuration.

Configuration.

See

GAubry\ErrorHandler\ErrorHandler::$aDefaultConfig
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0