没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\web\ErrorHandler

继承yii\web\ErrorHandler » yii\base\ErrorHandler » yii\base\Component » yii\base\BaseObject
实现yii\base\Configurable
可用版本自2.0
源码 https://github.com/yiichina/yii2/blob/api/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.

公共属性

隐藏继承的属性

属性类型描述被定义在
$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 是否在错误显示之前丢弃任何现有页面输出。默认为 true。 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 当前正在处理的异常。 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
$traceLine string Trace line with placeholders to be be substituted. yii\web\ErrorHandler

公共方法

隐藏继承的方法

方法描述被定义在
__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() 在调用此方法之前删除所有回显的输出。 yii\base\ErrorHandler
convertExceptionToError() 将异常转换为 PHP 错误。 yii\base\ErrorHandler
convertExceptionToString() 将异常转换为简单字符串。 yii\base\ErrorHandler
convertExceptionToVerboseString() 将异常转换为具有关于异常及其跟踪的详细信息的字符串。 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() 处理未捕获的 PHP 异常。 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() Initializes the object. yii\base\BaseObject
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() 注册此错误处理程序。 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() 通过还原 PHP 错误和异常处理程序取消注册此错误处理程序。 yii\base\ErrorHandler

受保护的方法

隐藏继承的方法

方法描述被定义在
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

属性详情

$callStackItemView 公共 属性

The path of the view file for rendering exceptions and errors call stack element.

public string $callStackItemView '@yii/views/errorHandler/callStackItem.php'
$displayVars 公共 属性 (自版本 2.0.7 可用)

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'].

参见 renderRequest().

public array $displayVars = ['_GET''_POST''_FILES''_COOKIE''_SESSION']
$errorAction 公共 属性

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.

public string $errorAction null
$errorView 公共 属性

The path of the view file for rendering exceptions without call stack information.

public string $errorView '@yii/views/errorHandler/error.php'
$exceptionView 公共 属性

The path of the view file for rendering exceptions.

public string $exceptionView '@yii/views/errorHandler/exception.php'
$maxSourceLines 公共 属性

Maximum number of source code lines to be displayed. Defaults to 19.

$maxTraceSourceLines 公共 属性

Maximum number of trace source code lines to be displayed. Defaults to 13.

$previousExceptionView 公共 属性

The path of the view file for rendering previous exceptions.

public string $previousExceptionView '@yii/views/errorHandler/previousException.php'
$traceLine 公共 属性 (自版本 2.0.14 可用)

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}

参见 https://github.com/yiisoft/yii2-debug#open-files-in-ide.

public string $traceLine '{html}'

方法详情

addTypeLinks() 公共 方法

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.

argumentsToString() 公共 方法

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

convertExceptionToArray() 受保护 方法

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.

createFrameworkVersionLink() 公共 方法

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.

createHttpStatusLink() 公共 方法

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.

createServerInformationLink() 公共 方法

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.

getExceptionName() 公共 方法

Returns human-readable exception name.

public string getExceptionName($exception)
$exception Exception
return string

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

getTypeUrl() 受保护 方法

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

参见 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.

htmlEncode() 公共 方法

Converts special characters to HTML entities.

public string htmlEncode($text)
$text string

To encode.

return string

Encoded original text.

isCoreFile() 公共 方法

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.

renderCallStack() 公共 方法 (自版本 2.0.12 可用)

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.

renderCallStackItem() 公共 方法

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.

renderException() 受保护 方法

Renders the exception.

protected void renderException($exception)
$exception Exception|Error

The exception to be rendered.

renderFile() 公共 方法

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

renderPreviousExceptions() 公共 方法

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.

renderRequest() 公共 方法

Renders the global variables of the request.

List of global variables is defined in $displayVars.

参见 $displayVars.

public string renderRequest()
return string

The rendering result

shouldRenderSimpleHtml() 受保护 方法 (自版本 2.0.12 可用)

protected boolean shouldRenderSimpleHtml()
return boolean

If simple HTML should be rendered