PHP Класс 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.
Наследование: extends StaticObject
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_checks Default checks are for code, stack and message.
$_config Configuration parameters.
$_exceptionHandler Currently registered exception handler.
$_isRunning State of error/exception handling.
$_runOptions

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
_origin ( array $stack ) : string Determine frame from the stack trace where the error/exception was first generated.

Описание методов

_origin() защищенный статический Метод

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.
Результат string Class where error/exception was generated.

apply() публичный статический Метод

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

config() публичный статический Метод

Configure the ErrorHandler.
public static config ( array $config = [] ) : Current
$config array Configuration directives.
Результат Current configuration set.

handle() публичный статический Метод

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
Результат boolean True if successfully handled, false otherwise.

isRunning() публичный статический Метод

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

matches() публичный статический Метод

public static 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.
public static reset ( )

run() публичный статический Метод

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() публичный статический Метод

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() публичный статический Метод

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.
Результат array Returns a flat stack array containing class and method references.

Описание свойств

$_checks защищенное статическое свойство

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

$_config защищенное статическое свойство

Configuration parameters.
protected static $_config

$_exceptionHandler защищенное статическое свойство

Currently registered exception handler.
protected static $_exceptionHandler

$_isRunning защищенное статическое свойство

State of error/exception handling.
protected static $_isRunning

$_runOptions защищенное статическое свойство

protected static $_runOptions