当前位置: 首页 > 后端技术 > PHP

Laravel5异常错误-Handler.php第38行FatalErrorException

时间:2023-03-29 18:55:18 PHP

1.FatalErrorExceptioninHandler.phpline38:UncaughtTypeError:Argument1passedtoApp\Exceptions\Handler::report()mustbeaninstanceofException,instanceofErrorgiven,calledinD:\www\activity\vendor\1.compiled.phponline1817定义在D:\www\activity\app\Exceptions\Handler.php:38Stacktrace:#0D:\www\activity\vendor\compiled.php(1817):App\Exceptions\Handler->report(Object(Error))#1[内部函数]:Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))#2{main}抛出原因:D:wwwactivityvendorcompiled.php1817行变量$eisnotaninstanceobjectofException(错误提示的翻译...^.^laughcry)2、解决方法是在提示错误的地方加上变量$e的实例判断。如果不是Exception类型,则新建一个if(!$einstanceof\Exception){$e=newFatalThrowableError($e);}new之后:publicfunctionhandleException($e){if(!$einstanceof\Exception){$e=newFatalThrowableError($e);}$this->getExceptionHandler()->report($e);如果($this->app->runningInConsole()){$this->renderForConsole($e);}else{$this->renderHttpResponse($e);}}