handleException($exception); exit(1); } } throw $exception; } else if(defined('YII_DEBUG') && $code < 2) { $this->getLog()->log($message, $code, $file); } } public function handleFatalError() { //unset($this->_memoryReserve); // load ErrorException manually here because autoloading them will not work // when error occurs while autoloading a class if (!class_exists('\\yii\\base\\Exception', false)) { require_once(__DIR__ . '/../vendor/yiisoft/yii2/base/Exception.php'); } if (!class_exists('\\yii\\base\\ErrorException', false)) { require_once(__DIR__ . '/../vendor/yiisoft/yii2/base/ErrorException.php'); } $error = error_get_last(); if (\yii\base\ErrorException::isFatalError($error)) { $exception = new \yii\base\ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']); $this->exception = $exception; // use error_log because it's too late to use Yii log error_log($exception); if (($handler = $this->getErrorHandler()) !== null) { $handler->handle($exception); } else { echo $this->renderException($exception); } $trace = debug_backtrace(false); array_shift($trace); \Yii::$app->getLog()->log($error['message'], $error['type'], $error['file']); } } }