laravel 5 Exception Error: FatalErrorException in Handler. php line 38 Resolution

  • 2021-08-10 06:59:59
  • OfStack

Preface

This article mainly introduces the solution of laravel5 abnormal error FatalErrorException in Handler. php line 38, and shares it for your reference and study. I won't say much. Let's take a look at the 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: D: wwwactivityvendorcompiled. php on line 1817 Variable $e is not an instance object of Exception

2. Solutions

Add an instance of the variable $e to the error where it is prompted. If it is not of Exception type, it will be new1


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

What new looks like after it is finished:


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

Summarize


Related articles: