ErrorHandler

Type
Class
Namespace
craft\web
Inherits
craft\web\ErrorHandler » yii\web\ErrorHandler » yii\base\ErrorHandler » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.0

Class ErrorHandler

View source

Public Properties

PropertyDescription
$behaviorsyii\base\Behavior – List of behaviors attached to this component
$callStackItemViewstring – The path of the view file for rendering exceptions and errors call stack element.
$discardExistingOutputboolean – Whether to discard any existing page output before error display.
$displayVarsarray – List of the PHP predefined variables that should be displayed on the error page.
$errorActionstring – The route (e.g. site/error) to the controller action that will be used to display external errors.
$errorViewstring – The path of the view file for rendering exceptions without call stack information.
$exceptionException, null – The exception that is being handled currently.
$exceptionViewstring – The path of the view file for rendering exceptions.
$maxSourceLinesinteger – Maximum number of source code lines to be displayed.
$maxTraceSourceLinesinteger – Maximum number of trace source code lines to be displayed.
$memoryReserveSizeinteger – The size of the reserved memory.
$previousExceptionViewstring – The path of the view file for rendering previous exceptions.
$traceLinestring – Trace line with placeholders to be be substituted.

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 an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
addTypeLinks()Adds informational links to the given PHP type/class.
argumentsToString()Converts arguments array to its string representation.
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.
createFrameworkVersionLink()Creates string containing HTML link which refers to the page with the current version of the framework and version number text.
createHttpStatusLink()Creates HTML containing link to the page with the information on given HTTP status code.
createServerInformationLink()Creates string containing HTML link which refers to the home page of determined web-server software and its full name.
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.
getExceptionName()Returns human-readable exception name.
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.
htmlEncode()Converts special characters to HTML entities.
init()Initializes the object.
isCoreFile()Determines whether given name of the file belongs to the framework.
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.
renderCallStack()Renders call stack.
renderCallStackItem()Renders a single call stack element.
renderFile()Renders a view file as a PHP script.
renderPreviousExceptions()Renders the previous exception stack for a given Exception.
renderRequest()Renders the global variables of the request.
trigger()Triggers an event.
unregister()Unregisters this error handler by restoring the PHP error and exception handlers.

getExceptionName()

Returns human-readable exception name.

View source

Arguments

Returns

string – Human-readable exception name or null if it cannot be determined

Signature

public string getExceptionName ( $exception )

handleError()

Handles PHP execution errors such as warnings and notices.

This method is used as a PHP error handler. It will simply raise an \craft\web\ErrorException.

View source

Arguments

  • $code (integer) – The level of the error raised.
  • $message (string) – The error message.
  • $file (string) – The filename that the error was raised in.
  • $line (integer) – The line number the error was raised at.

Returns

boolean – Whether the normal error handler continues.

Throws

Signature

public boolean handleError ( $code, $message, $file, $line )

handleException()

Handles uncaught PHP exceptions.

This method is implemented as a PHP exception handler.

View source

Arguments

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

Signature

public void handleException ( $exception )

isCoreFile()

Determines whether given name of the file belongs to the framework.

View source

Arguments

  • $file (string) – Name to be checked.

Returns

boolean – Whether given name of the file belongs to the framework.

Signature

public boolean isCoreFile ( $file )

Protected Methods

MethodDescription
convertExceptionToArray()Converts an exception into an array.
getTypeUrl()Returns the informational link URL for a given PHP type/class.
handleFallbackExceptionMessage()Handles exception thrown during exception processing in handleException().
renderException()Renders the exception.
shouldRenderSimpleHtml()

getTypeUrl()

Returns the informational link URL for a given PHP type/class.

View source

Arguments

  • $class (string) – The type or class name.
  • $method (string, null) – The method name.

Returns

string, null – The informational link URL.

Signature

protected string, null getTypeUrl ( $class, $method )

renderException()

Renders the exception.

View source

Arguments

Signature

protected void renderException ( $exception )

Events

EVENT_BEFORE_HANDLE_EXCEPTION

Type
craft\events\ExceptionEvent

The event that is triggered before handling an exception.