laravel5異常錯誤-FatalErrorException in Handler.php line 38

一、錯誤提示php

FatalErrorException in Handler.php line 38:
Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in D:\www\activity\vendor\compiled.php on line 1817 and defined in D:\www\activity\app\Exceptions\Handler.php:38
Stack trace:
#0 D:\www\activity\vendor\compiled.php(1817): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
thrown

緣由:D:wwwactivityvendorcompiled.php on line 1817 的變量$e不是Exception的實例對象(對錯誤提示的翻譯……^.^笑cry)app

二、解決方案
在提示的錯誤地方加上變量$e的實例判斷,若是不是Exception類型,就new一個this

if (!$e instanceof \Exception) {
    $e = new FatalThrowableError($e);
}

new完以後的樣子:翻譯

public function handleException($e)
{
    if (!$e instanceof \Exception) {
        $e = new FatalThrowableError($e);
    }
    $this->getExceptionHandler()->report($e);
    if ($this->app->runningInConsole()) {
        $this->renderForConsole($e);
    } else {
        $this->renderHttpResponse($e);
    }
}
相關文章
相關標籤/搜索