0 フォロワー

クラス yii\base\ErrorException

継承yii\base\ErrorException » ErrorException
利用可能なバージョン2.0
ソースコード https://github.com/yiisoft/yii2/blob/master/framework/base/ErrorException.php

ErrorException は PHP エラーを表します。

ErrorException の詳細および使用方法については、エラー処理に関するガイド記事をご覧ください。

パブリックメソッド

継承されたメソッドを非表示

メソッド 説明 定義元
__construct() 例外を構築します。 yii\base\ErrorException
getName() yii\base\ErrorException
isFatalError() エラーが致命的なタイプであるかどうかを返します。 yii\base\ErrorException

定数

継承された定数を非表示

定数 説明 定義元
E_HHVM_FATAL_ERROR 16777217 この定数は、HHVM エンジンでの致命的なエラーを表します。PHP Zend ランタイムは致命的なエラーでエラーハンドラーを呼び出しませんが、HHVM はエラーコード 16777217 で呼び出します。HHVM では致命的なエラーの処理を少し異なります。 yii\base\ErrorException

メソッドの詳細

継承されたメソッドを非表示

__construct() パブリックメソッド

例外を構築します。

public void __construct ( $message '', $code 0, $severity 1, $filename __FILE__, $lineno __LINE__, $previous null )
$message string

[オプション]

$code integer

[オプション]

$severity integer

[オプション]

$filename string

[オプション]

$lineno integer

[オプション]

$previous Throwable|null

[オプション]

                public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, $previous = null)
{
    parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
    if ($this->isXdebugStackAvailable()) {
        // Xdebug trace can't be modified and used directly with PHP 7
        // @see https://github.com/yiisoft/yii2/pull/11723
        $xdebugTrace = array_slice(array_reverse(xdebug_get_function_stack()), 1, -1);
        $trace = [];
        foreach ($xdebugTrace as $frame) {
            if (!isset($frame['function'])) {
                $frame['function'] = 'unknown';
            }
            // Xdebug < 2.1.1: https://bugs.xdebug.org/view.php?id=695
            if (!isset($frame['type']) || $frame['type'] === 'static') {
                $frame['type'] = '::';
            } elseif ($frame['type'] === 'dynamic') {
                $frame['type'] = '->';
            }
            // Xdebug has a different key name
            if (isset($frame['params']) && !isset($frame['args'])) {
                $frame['args'] = $frame['params'];
            }
            $trace[] = $frame;
        }
        $ref = new \ReflectionProperty('Exception', 'trace');
        $ref->setAccessible(true);
        $ref->setValue($this, $trace);
    }
}

            
getName() パブリックメソッド

public string getName ( )
return string

この例外のユーザーフレンドリーな名前

                public function getName()
{
    static $names = [
        E_COMPILE_ERROR => 'PHP Compile Error',
        E_COMPILE_WARNING => 'PHP Compile Warning',
        E_CORE_ERROR => 'PHP Core Error',
        E_CORE_WARNING => 'PHP Core Warning',
        E_DEPRECATED => 'PHP Deprecated Warning',
        E_ERROR => 'PHP Fatal Error',
        E_NOTICE => 'PHP Notice',
        E_PARSE => 'PHP Parse Error',
        E_RECOVERABLE_ERROR => 'PHP Recoverable Error',
        E_STRICT => 'PHP Strict Warning',
        E_USER_DEPRECATED => 'PHP User Deprecated Warning',
        E_USER_ERROR => 'PHP User Error',
        E_USER_NOTICE => 'PHP User Notice',
        E_USER_WARNING => 'PHP User Warning',
        E_WARNING => 'PHP Warning',
        self::E_HHVM_FATAL_ERROR => 'HHVM Fatal Error',
    ];
    return isset($names[$this->getCode()]) ? $names[$this->getCode()] : 'Error';
}

            
isFatalError() パブリック静的メソッド

エラーが致命的なタイプであるかどうかを返します。

public static boolean isFatalError ( $error )
$error array

error_get_last() から取得したエラー

return boolean

エラーが致命的なタイプの場合

                public static function isFatalError($error)
{
    return isset($error['type']) && in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, self::E_HHVM_FATAL_ERROR]);
}