欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

laravel 5异常FatalErrorException in Handler.php line 38如何解决

程序员文章站 2022-04-06 19:05:14
...
本文主要给大家介绍了关于laravel 5异常错误:FatalErrorException in Handler.php line 38的解决方法,文中将解决方法介绍的非常详细,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧。希望能帮助到大家。

前言

本文主要给大家介绍了关于laravel5异常错误FatalErrorException in Handler.php line 38的解决,分享出来供大家参考学习,话不多说了,来一起看看详细的介绍。

1、错误提示

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)

2、解决方案

在提示的错误地方加上变量$e的实例判断,如果不是Exception类型,就new一个

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);
 }
}

相关推荐:

详解如何在iis 7下安装laravel 5.4环境

提升Laravel 5性能的一些实用技巧

使用laravel 5.1出现No supported encrypter found报错的解决方法

以上就是laravel 5异常FatalErrorException in Handler.php line 38如何解决的详细内容,更多请关注其它相关文章!