Class yii\web\ErrorHandler
Inheritance | yii\web\ErrorHandler » yii\base\ErrorHandler » yii\base\Component » yii\base\Object |
---|---|
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
.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component | 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 |
$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 | 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 |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Object |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\Object |
__get() | Returns the value of an object property. | yii\base\Object |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Object |
__set() | Sets value of an object property. | yii\base\Object |
__unset() | Sets an object property to null. | yii\base\Object |
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\Object |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Object |
className() | Returns the fully qualified name of this class. | yii\base\Object |
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 |
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 |
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\Object |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\Object |
htmlEncode() | Converts special characters to HTML entities. | yii\web\ErrorHandler |
init() | Initializes the object. | yii\base\Object |
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 |
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 request information. | 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 |
renderException() | Renders the exception. | yii\web\ErrorHandler |
Property Details
The path of the view file for rendering exceptions and errors call stack element.
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.
Method Details
Adds informational links to the given PHP type/class.
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
string argumentsToString( $args ) | ||
$args | array | Arguments array to be converted |
return | string | String representation of the arguments array |
---|
Converts an exception into an array.
array convertExceptionToArray( $exception ) | ||
$exception | Exception | 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.
string createFrameworkVersionLink( ) | ||
return | string | Framework version information hyperlink. |
---|
Creates HTML containing link to the page with the information on given HTTP status code.
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.
string createServerInformationLink( ) | ||
return | string | Server software information hyperlink. |
---|
Returns human-readable exception name
string getExceptionName( $exception ) | ||
$exception | Exception | |
return | string | 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().
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.
string htmlEncode( $text ) | ||
$text | string | To encode. |
return | string | Encoded original text. |
---|
Determines whether given name of the file belongs to the framework.
boolean isCoreFile( $file ) | ||
$file | string | Name to be checked. |
return | boolean | Whether given name of the file belongs to the framework. |
---|
Renders a single call stack element.
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.
void renderException( $exception ) | ||
$exception | Exception | The exception to be rendered. |
Renders a view file as a PHP script.
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.
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 request information.
string renderRequest( ) | ||
return | string | The rendering result |
---|