laravel 5异常错误:FatalErrorException in Handler.php line 38的解决

2025-05-29 0 29

前言

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

1、错误提示

?

1

2

3

4

5

6

7
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一个

?

1

2

3
if (!$e instanceof \\Exception) {

$e = new FatalThrowableError($e);

}

new完之后的样子:

?

1

2

3

4

5

6

7

8

9

10

11

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

}

}

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对快网idc的支持。

原文链接:https://segmentfault.com/a/1190000011496178

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 laravel 5异常错误:FatalErrorException in Handler.php line 38的解决 https://www.kuaiidc.com/93239.html

相关文章

发表评论
暂无评论