Home  >  Article  >  Backend Development  >  How to solve laravel 5 exception FatalErrorException in Handler.php line 38

How to solve laravel 5 exception FatalErrorException in Handler.php line 38

小云云
小云云Original
2018-01-06 16:03:341508browse

This article mainly introduces to you the solution to the laravel 5 exception error: FatalErrorException in Handler.php line 38. The solution is introduced in great detail. Friends in need can refer to it. Follow the editor to learn together. Study it. Hope it helps everyone.

Preface

This article mainly introduces to you the solution to the laravel5 exception error FatalErrorException in Handler.php line 38. It is shared for your reference and study. Without further ado, let’s take a look. detailed introduction.

1. Error prompt

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

Reason: The variable $e in D:wwwactivityvendorcompiled.php on line 1817 is not an instance object of Exception (translation of the error prompt...^.^laughing)

2. Solution

Add the instance judgment of variable $e in the error prompt. If it is not an Exception type, just create a new one

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

new. What it looks like after:

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

Related recommendations:

Details on how to install laravel 5.4 environment under iis 7

Improve Laravel 5. Some practical tips on performance

Solution to the No supported encrypter found error when using laravel 5.1

The above is the detailed content of How to solve laravel 5 exception FatalErrorException in Handler.php line 38. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn