没有命名空间的类 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

Abstract Class yii\base\ErrorHandler

继承yii\base\ErrorHandler » yii\base\Component » yii\base\BaseObject
实现yii\base\Configurable
子类yii\console\ErrorHandler, yii\web\ErrorHandler
可用版本自2.0
源码 https://github.com/yiichina/yii2/blob/api/framework/base/ErrorHandler.php

ErrorHandler 处理未捕获的 PHP 错误和异常。

默认情况下,ErrorHandler 在 yii\base\Application 中配置为应用程序组件。 您可以通过 Yii::$app->errorHandler 访问该实例。

有关 ErrorHandler 的更多详细信息和用法信息,请参阅 有关错误处理的指南文章

公共属性

隐藏继承的属性

属性类型描述被定义在
$behaviors yii\base\Behavior[] List of behaviors attached to this component yii\base\Component
$discardExistingOutput boolean 是否在错误显示之前丢弃任何现有页面输出。默认为 true。 yii\base\ErrorHandler
$exception Exception|null 当前正在处理的异常。 yii\base\ErrorHandler
$memoryReserveSize integer The size of the reserved memory. yii\base\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
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
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
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
init() Initializes the object. yii\base\BaseObject
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
trigger() Triggers an event. yii\base\Component
unregister() 通过还原 PHP 错误和异常处理程序取消注册此错误处理程序。 yii\base\ErrorHandler

受保护的方法

隐藏继承的方法

方法描述被定义在
handleFallbackExceptionMessage() Handles exception thrown during exception processing in handleException(). yii\base\ErrorHandler
renderException() Renders the exception. yii\base\ErrorHandler

属性详情

$discardExistingOutput 公共 属性

是否在错误显示之前丢弃任何现有页面输出。默认为 true。

$exception 公共 属性

当前正在处理的异常。

public Exception|null $exception null
$memoryReserveSize 公共 属性

The size of the reserved memory. A portion of memory is pre-allocated so that when an out-of-memory issue occurs, the error handler is able to handle the error with the help of this reserved memory. If you set this value to be 0, no memory will be reserved. Defaults to 256KB.

public integer $memoryReserveSize 262144

方法详情

clearOutput() 公共 方法

在调用此方法之前删除所有回显的输出。

public void clearOutput()
convertExceptionToError() 公共 静态 方法

将异常转换为 PHP 错误。

此方法可用于将类似 __toString() 的方法内的异常转换为 PHP 错误,因为异常不能在其中抛出。

public static void convertExceptionToError($exception)
$exception Exception

转换为 PHP 错误的异常。

convertExceptionToString() 公共 静态 方法

将异常转换为简单字符串。

public static string convertExceptionToString($exception)
$exception Exception|Error

被转换的异常

return string

异常的字符串表示形式。

convertExceptionToVerboseString() 公共 静态 方法 (自版本 2.0.14 可用)

将异常转换为具有关于异常及其跟踪的详细信息的字符串。

public static string convertExceptionToVerboseString($exception)
$exception Exception|Error

被转换的异常

return string

异常的字符串表示形式。

handleError() 公共 方法

Handles PHP execution errors such as warnings and notices.

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

public boolean handleError($code, $message, $file, $line)
$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.

return boolean

Whether the normal error handler continues.

throws yii\base\ErrorException
handleException() 公共 方法

处理未捕获的 PHP 异常。

此方法实现为 PHP 异常处理程序。

public void handleException($exception)
$exception Exception

未捕获的异常

handleFallbackExceptionMessage() 受保护 方法 (自版本 2.0.11 可用)

Handles exception thrown during exception processing in handleException().

protected void handleFallbackExceptionMessage($exception, $previousException)
$exception Exception|Throwable

Exception that was thrown during main exception processing.

$previousException Exception

Main exception processed in handleException().

handleFatalError() 公共 方法

Handles fatal PHP errors.

public void handleFatalError()
handleHhvmError() 公共 方法 (自版本 2.0.6 可用)

Handles HHVM execution errors such as warnings and notices.

This method is used as a HHVM error handler. It will store exception that will be used in fatal error handler

public boolean handleHhvmError($code, $message, $file, $line, $context, $backtrace)
$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.

$context mixed
$backtrace mixed

Trace of error

return boolean

Whether the normal error handler continues.

throws yii\base\ErrorException
logException() 公共 方法 (自版本 2.0.3 可用)

Logs the given exception.

public void logException($exception)
$exception Exception

The exception to be logged

register() 公共 方法

注册此错误处理程序。

public void register()
renderException() 受保护 抽象 方法

Renders the exception.

protected abstract void renderException($exception)
$exception Exception

The exception to be rendered.

unregister() 公共 方法

通过还原 PHP 错误和异常处理程序取消注册此错误处理程序。

public void unregister()