首页 > 开发 > PHP > 正文

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

2024-05-04 21:50:06
字体:
来源:转载
供稿:网友

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

1、错误提示

  1. FatalErrorException in Handler.php line 38: 
  2. 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 
  3. Stack trace: 
  4. #0 D:/www/activity/vendor/compiled.php(1817): App/Exceptions/Handler->report(Object(Error)) 
  5. #1 [internal function]: Illuminate/Foundation/Bootstrap/HandleExceptions->handleException(Object(Error)) 
  6. #2 {main} 
  7. thrown 

原因:D:wwwactivityvendorcompiled.php on line 1817 的变量$e不是Exception的实例对象(对错误提示的翻译……^.^笑cry)

2、解决方案

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

  1. if (!$e instanceof /Exception) { 
  2.  $e = new FatalThrowableError($e); 

new完之后的样子:

  1. public function handleException($e
  2.  if (!$e instanceof /Exception) { 
  3.   $e = new FatalThrowableError($e); 
  4.  } 
  5.  $this->getExceptionHandler()->report($e); 
  6.  if ($this->app->runningInConsole()) { 
  7.   $this->renderForConsole($e); 
  8.  } else { 
  9.   $this->renderHttpResponse($e); 
  10.  } //Vevb.com 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表