PHP Class lithium\core\ErrorHandler

{{{ embed:lithium\tests\cases\core\ErrorHandlerTest::testExceptionCatching(2-7) }}} Using a series of cascading rules and handlers, it is possible to capture and handle very specific errors and exceptions.
Inheritance: extends StaticObject
Afficher le fichier Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Свойство Type Description
$_checks Default checks are for code, stack and message.
$_config Configuration parameters.
$_exceptionHandler Currently registered exception handler.
$_isRunning State of error/exception handling.
$_runOptions

Méthodes publiques

Méthode Description
apply ( $object, array $conditions, $handler )
config ( array $config = [] ) : Current Configure the ErrorHandler.
handle ( object | array $info, array $scope = [] ) : boolean Receives the handled errors and exceptions that have been caught, and processes them in a normalized manner.
isRunning ( ) Returns the state of the ErrorHandler, indicating whether or not custom error/exception handers have been regsitered.
matches ( $info, $conditions )
reset ( ) Setup basic error handling checks/types, as well as register the error and exception handlers and wipes out all configuration and resets the error handler to its initial state when loaded. Mainly used for testing.
run ( array $config = [] ) Register error and exception handlers.
stop ( ) Unooks ErrorHandler's exception and error handlers, and restores PHP's defaults. May have unexpected results if it is not matched with a prior call to run(), or if other error handlers are set after a call to run().
trace ( array $stack ) : array Trim down a typical stack trace to class & method calls.

Méthodes protégées

Méthode Description
_origin ( array $stack ) : string Determine frame from the stack trace where the error/exception was first generated.

Method Details

_origin() protected static méthode

Determine frame from the stack trace where the error/exception was first generated.
protected static _origin ( array $stack ) : string
$stack array Stack trace from error/exception that was produced.
Résultat string Class where error/exception was generated.

apply() public static méthode

public static apply ( $object, array $conditions, $handler )
$conditions array

config() public static méthode

Configure the ErrorHandler.
public static config ( array $config = [] ) : Current
$config array Configuration directives.
Résultat Current configuration set.

handle() public static méthode

Receives the handled errors and exceptions that have been caught, and processes them in a normalized manner.
public static handle ( object | array $info, array $scope = [] ) : boolean
$info object | array
$scope array
Résultat boolean True if successfully handled, false otherwise.

isRunning() public static méthode

Returns the state of the ErrorHandler, indicating whether or not custom error/exception handers have been regsitered.
public static isRunning ( )

matches() public static méthode

public static matches ( $info, $conditions )

reset() public static méthode

Setup basic error handling checks/types, as well as register the error and exception handlers and wipes out all configuration and resets the error handler to its initial state when loaded. Mainly used for testing.
public static reset ( )

run() public static méthode

This method (ErrorHandler::run()) needs to be called as early as possible in the bootstrap cycle; immediately after require-ing bootstrap/libraries.php is your best bet.
public static run ( array $config = [] )
$config array The configuration with which to start the error handler. Available options include: - `'trapErrors'` _boolean_: Defaults to `false`. If set to `true`, PHP errors will be caught by `ErrorHandler` and handled in-place. Execution will resume in the same context in which the error occurred. - `'convertErrors'` _boolean_: Defaults to `true`, and specifies that all PHP errors should be converted to `ErrorException`s and thrown from the point where the error occurred. The exception will be caught at the first point in the stack trace inside a matching `try`/`catch` block, or that has a matching error handler applied using the `apply()` method.

stop() public static méthode

Unooks ErrorHandler's exception and error handlers, and restores PHP's defaults. May have unexpected results if it is not matched with a prior call to run(), or if other error handlers are set after a call to run().
public static stop ( )

trace() public static méthode

Trim down a typical stack trace to class & method calls.
public static trace ( array $stack ) : array
$stack array A `debug_backtrace()`-compatible stack trace output.
Résultat array Returns a flat stack array containing class and method references.

Property Details

$_checks protected_oe static_oe property

Default checks are for code, stack and message.
protected static $_checks

$_config protected_oe static_oe property

Configuration parameters.
protected static $_config

$_exceptionHandler protected_oe static_oe property

Currently registered exception handler.
protected static $_exceptionHandler

$_isRunning protected_oe static_oe property

State of error/exception handling.
protected static $_isRunning

$_runOptions protected_oe static_oe property

protected static $_runOptions