class ErrorHandler
A generic ErrorHandler for the PHP engine.
Provides five bit fields that control how errors are handled: - thrownErrors: errors thrown as \ErrorException - loggedErrors: logged errors, when not @-silenced - scopedErrors: errors thrown or logged with their local context - tracedErrors: errors logged with their stack trace, only once for repeated errors - screamedErrors: never @-silenced errors
Each error level can be logged by a dedicated PSR-3 logger object. Screaming only applies to logging. Throwing takes precedence over logging. Uncaught exceptions are logged as EERROR. EDEPRECATED and EUSERDEPRECATED levels never throw. ERECOVERABLEERROR and EUSERERROR levels always throw. Non catchable errors that can be detected at shutdown time are logged when the scream bit field allows so. As errors have a performance cost, repeated errors are all logged, so that the developer can see them and weight them as more important to fix than others of the same level.
TYPE_DEPRECATION |
static ErrorHandler | register(ErrorHandler|null|int $handler = null, bool $replace = true) Registers the error handler. | |
setDefaultLogger(LoggerInterface $logger, array|int $levels = null, bool $replace = false) Sets a logger to non assigned errors levels. | ||
array | setLoggers(array $loggers) Sets a logger for each error level. | |
callable|null | setExceptionHandler(callable $handler) Sets a user exception handler. | |
int | throwAt(int $levels, bool $replace = false) Sets the error levels that are to be thrown. | |
int | scopeAt(int $levels, bool $replace = false) Sets the error levels that are logged or thrown with their local scope. | |
int | traceAt(int $levels, bool $replace = false) Sets the error levels that are logged with their stack trace. | |
int | screamAt(int $levels, bool $replace = false) Sets the error levels where the @-operator is ignored. | |
bool | handleError($type, $message, $file, $line, array $context) Handles errors by filtering then logging them according to the configured bit fields. | |
handleException(Exception $exception, array $error = null) Handles an exception by logging then forwarding it to an other handler. | ||
static | handleFatalError(array $error = null) Shutdown registered function for handling PHP fatal errors. | |
static | stackErrors() Configures the error handler for delayed handling. | |
static | unstackErrors() Unstacks stacked errors and forwards to the logger | |
setLevel(int|null $level) Sets the level at which the conversion to Exception is done. | ||
setDisplayErrors(int $displayErrors) Sets the display_errors flag value. | ||
static | setLogger(LoggerInterface $logger, string $channel = 'deprecation') Sets a logger for the given channel. | |
handle($level, $message, $file = 'unknown', $line, $context = array()) | ||
handleFatal() Handles PHP fatal errors. |
Registers the error handler.
Sets a logger to non assigned errors levels.
Sets a logger for each error level.
Sets a user exception handler.
Sets the error levels that are to be thrown.
Sets the error levels that are logged or thrown with their local scope.
Sets the error levels that are logged with their stack trace.
Sets the error levels where the @-operator is ignored.
Handles errors by filtering then logging them according to the configured bit fields.
Handles an exception by logging then forwarding it to an other handler.
Shutdown registered function for handling PHP fatal errors.
Configures the error handler for delayed handling.
Ensures also that non-catchable fatal errors are never silenced.
As shown by http://bugs.php.net/42098 and http://bugs.php.net/60724 PHP has a compile stage where it behaves unusually. To workaround it, we plug an error handler that only stacks errors for later.
The most important feature of this is to prevent autoloading until unstackErrors() is called.
Unstacks stacked errors and forwards to the logger
Sets the level at which the conversion to Exception is done.
Sets the display_errors flag value.
Sets a logger for the given channel.
Handles PHP fatal errors.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/Debug/ErrorHandler.html