Class yii\web\ErrorHandler
Inheritance | yii\web\ErrorHandler » yii\base\ErrorHandler » yii\base\Component » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/web/ErrorHandler.php |
ErrorHandler handles uncaught PHP errors and exceptions.
ErrorHandler displays these errors using appropriate views based on the nature of the errors and the mode the application runs at.
ErrorHandler is configured as an application component in yii\base\Application by default.
You can access that instance via Yii::$app->errorHandler
.
For more details and usage information on ErrorHandler, see the guide article on handling errors.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component. This property is read-only. | yii\base\Component |
$callStackItemView | string | The path of the view file for rendering exceptions and errors call stack element. | yii\web\ErrorHandler |
$discardExistingOutput | boolean | Whether to discard any existing page output before error display. | yii\base\ErrorHandler |
$displayVars | array | List of the PHP predefined variables that should be displayed on the error page. | yii\web\ErrorHandler |
$errorAction | string | The route (e.g. site/error ) to the controller action that will be used
to display external errors. |
yii\web\ErrorHandler |
$errorView | string | The path of the view file for rendering exceptions without call stack information. | yii\web\ErrorHandler |
$exception | Exception|null | The exception that is being handled currently. | yii\base\ErrorHandler |
$exceptionView | string | The path of the view file for rendering exceptions. | yii\web\ErrorHandler |
$maxSourceLines | integer | Maximum number of source code lines to be displayed. | yii\web\ErrorHandler |
$maxTraceSourceLines | integer | Maximum number of trace source code lines to be displayed. | yii\web\ErrorHandler |
$memoryReserveSize | integer | The size of the reserved memory. | yii\base\ErrorHandler |
$previousExceptionView | string | The path of the view file for rendering previous exceptions. | yii\web\ErrorHandler |
$silentExitOnException | boolean | If true - handleException() will finish script with ExitCode::OK . |
yii\base\ErrorHandler |
$traceLine | string | Trace line with placeholders to be be substituted. | yii\web\ErrorHandler |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of a component property. | yii\base\Component |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component |
__set() | Sets the value of a component property. | yii\base\Component |
__unset() | Sets a component property to be null. | yii\base\Component |
addTypeLinks() | Adds informational links to the given PHP type/class. | yii\web\ErrorHandler |
argumentsToString() | Converts arguments array to its string representation. | yii\web\ErrorHandler |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
clearOutput() | Removes all output echoed before calling this method. | yii\base\ErrorHandler |
convertExceptionToError() | Converts an exception into a PHP error. | yii\base\ErrorHandler |
convertExceptionToString() | Converts an exception into a simple string. | yii\base\ErrorHandler |
convertExceptionToVerboseString() | Converts an exception into a string that has verbose information about the exception and its trace. | yii\base\ErrorHandler |
createFrameworkVersionLink() | Creates string containing HTML link which refers to the page with the current version of the framework and version number text. | yii\web\ErrorHandler |
createHttpStatusLink() | Creates HTML containing link to the page with the information on given HTTP status code. | yii\web\ErrorHandler |
createServerInformationLink() | Creates string containing HTML link which refers to the home page of determined web-server software and its full name. | yii\web\ErrorHandler |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getExceptionName() | Returns human-readable exception name. | yii\web\ErrorHandler |
handleError() | Handles PHP execution errors such as warnings and notices. | yii\base\ErrorHandler |
handleException() | Handles uncaught PHP exceptions. | yii\base\ErrorHandler |
handleFatalError() | Handles fatal PHP errors. | yii\base\ErrorHandler |
handleHhvmError() | Handles HHVM execution errors such as warnings and notices. | yii\base\ErrorHandler |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
htmlEncode() | Converts special characters to HTML entities. | yii\web\ErrorHandler |
init() | yii\base\ErrorHandler | |
isCoreFile() | Determines whether given name of the file belongs to the framework. | yii\web\ErrorHandler |
logException() | Logs the given exception. | yii\base\ErrorHandler |
off() | Detaches an existing event handler from this component. | yii\base\Component |
on() | Attaches an event handler to an event. | yii\base\Component |
register() | Register this error handler. | yii\base\ErrorHandler |
renderCallStack() | Renders call stack. | yii\web\ErrorHandler |
renderCallStackItem() | Renders a single call stack element. | yii\web\ErrorHandler |
renderFile() | Renders a view file as a PHP script. | yii\web\ErrorHandler |
renderPreviousExceptions() | Renders the previous exception stack for a given Exception. | yii\web\ErrorHandler |
renderRequest() | Renders the global variables of the request. | yii\web\ErrorHandler |
trigger() | Triggers an event. | yii\base\Component |
unregister() | Unregisters this error handler by restoring the PHP error and exception handlers. | yii\base\ErrorHandler |
Protected Methods
Method | Description | Defined By |
---|---|---|
convertExceptionToArray() | Converts an exception into an array. | yii\web\ErrorHandler |
getTypeUrl() | Returns the informational link URL for a given PHP type/class. | yii\web\ErrorHandler |
handleFallbackExceptionMessage() | Handles exception thrown during exception processing in handleException(). | yii\base\ErrorHandler |
renderException() | Renders the exception. | yii\web\ErrorHandler |
shouldRenderSimpleHtml() | yii\web\ErrorHandler |
Property Details
The path of the view file for rendering exceptions and errors call stack element.
List of the PHP predefined variables that should be displayed on the error page.
Note that a variable must be accessible via $GLOBALS
. Otherwise it won't be displayed.
Defaults to ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION']
.
See also renderRequest().
The route (e.g. site/error
) to the controller action that will be used
to display external errors. Inside the action, it can retrieve the error information
using Yii::$app->errorHandler->exception
. This property defaults to null, meaning ErrorHandler
will handle the error display.
The path of the view file for rendering exceptions without call stack information.
The path of the view file for rendering exceptions.
Maximum number of source code lines to be displayed. Defaults to 19.
Maximum number of trace source code lines to be displayed. Defaults to 13.
The path of the view file for rendering previous exceptions.
Trace line with placeholders to be be substituted. The placeholders are {file}, {line} and {text} and the string should be as follows.
File: {file} - Line: {line} - Text: {text}
See also https://github.com/yiisoft/yii2-debug#open-files-in-ide.
Method Details
Adds informational links to the given PHP type/class.
public string addTypeLinks ( $code ) | ||
$code | string | Type/class name to be linkified. |
return | string | Linkified with HTML type/class name. |
---|
Converts arguments array to its string representation.
public string argumentsToString ( $args ) | ||
$args | array | Arguments array to be converted |
return | string | String representation of the arguments array |
---|
Converts an exception into an array.
protected array convertExceptionToArray ( $exception ) | ||
$exception | Exception|Error | The exception being converted |
return | array | The array representation of the exception. |
---|
Creates string containing HTML link which refers to the page with the current version of the framework and version number text.
public string createFrameworkVersionLink ( ) | ||
return | string | Framework version information hyperlink. |
---|
Creates HTML containing link to the page with the information on given HTTP status code.
public string createHttpStatusLink ( $statusCode, $statusDescription ) | ||
$statusCode | integer | To be used to generate information link. |
$statusDescription | string | Description to display after the the status code. |
return | string | Generated HTML with HTTP status code information. |
---|
Creates string containing HTML link which refers to the home page of determined web-server software and its full name.
public string createServerInformationLink ( ) | ||
return | string | Server software information hyperlink. |
---|
Returns human-readable exception name.
public string|null getExceptionName ( $exception ) | ||
$exception | Exception | |
return | string|null | Human-readable exception name or null if it cannot be determined |
---|
Returns the informational link URL for a given PHP type/class.
See also addTypeLinks().
protected string|null getTypeUrl ( $class, $method ) | ||
$class | string | The type or class name. |
$method | string|null | The method name. |
return | string|null | The informational link URL. |
---|
Converts special characters to HTML entities.
public string htmlEncode ( $text ) | ||
$text | string | To encode. |
return | string | Encoded original text. |
---|
Determines whether given name of the file belongs to the framework.
public boolean isCoreFile ( $file ) | ||
$file | string | Name to be checked. |
return | boolean | Whether given name of the file belongs to the framework. |
---|
Renders call stack.
public string renderCallStack ( $exception ) | ||
$exception | Exception|ParseError | Exception to get call stack from |
return | string | HTML content of the rendered call stack. |
---|
Renders a single call stack element.
public string renderCallStackItem ( $file, $line, $class, $method, $args, $index ) | ||
$file | string|null | Name where call has happened. |
$line | integer|null | Number on which call has happened. |
$class | string|null | Called class name. |
$method | string|null | Called function/method name. |
$args | array | Array of method arguments. |
$index | integer | Number of the call stack element. |
return | string | HTML content of the rendered call stack element. |
---|
Renders the exception.
protected void renderException ( $exception ) | ||
$exception | Exception|Error | The exception to be rendered. |
Renders a view file as a PHP script.
public string renderFile ( $_file_, $_params_ ) | ||
$_file_ | string | The view file. |
$_params_ | array | The parameters (name-value pairs) that will be extracted and made available in the view file. |
return | string | The rendering result |
---|
Renders the previous exception stack for a given Exception.
public string renderPreviousExceptions ( $exception ) | ||
$exception | Exception | The exception whose precursors should be rendered. |
return | string | HTML content of the rendered previous exceptions. Empty string if there are none. |
---|
Renders the global variables of the request.
List of global variables is defined in $displayVars.
See also $displayVars.
public string renderRequest ( ) | ||
return | string | The rendering result |
---|
protected boolean shouldRenderSimpleHtml ( ) | ||
return | boolean | If simple HTML should be rendered |
---|
Signup or Login in order to comment.