Skip to content

ErrorHandler ​

Type
Class
Namespace
craft\console
Inherits
craft\console\ErrorHandler » yii\console\ErrorHandler » yii\base\ErrorHandler » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.7.18

Class ErrorHandler

View source

Public Properties ​

PropertyDescription
behaviorsyii\base\Behavior – List of behaviors attached to this component.
discardExistingOutputboolean – Whether to discard any existing page output before error display.
exceptionThrowable, null – The exception that is being handled currently.
memoryReserveSizeinteger – The size of the reserved memory.
silentExitOnExceptionboolean – If true - handleException() will finish script with ExitCode::OK.

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
clearOutput()Removes all output echoed before calling this method.
convertExceptionToError()Converts an exception into a PHP error.
convertExceptionToString()Converts an exception into a simple string.
convertExceptionToVerboseString()Converts an exception into a string that has verbose information about the exception and its trace.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
handleError()Handles PHP execution errors such as warnings and notices.
handleException()Handles uncaught PHP exceptions.
handleFatalError()Handles fatal PHP errors.
handleHhvmError()Handles HHVM execution errors such as warnings and notices.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
init()
logException()Logs the given exception.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
register()Register this error handler.
trigger()Triggers an event.
unregister()Unregisters this error handler by restoring the PHP error and exception handlers.

handleException() ​

Handles uncaught PHP exceptions.

This method is implemented as a PHP exception handler.

View source

Arguments ​

  • $exception (Throwable) – The exception that is not caught

Protected Methods ​

MethodDescription
formatMessage()Colorizes a message for console output.
handleFallbackExceptionMessage()Handles exception thrown during exception processing in handleException().
renderException()Renders an exception using ansi format for console output.

Events ​

EVENT_BEFORE_HANDLE_EXCEPTION ​

Type
craft\events\ExceptionEvent

The event that is triggered before handling an exception.