Uncaught TypeError: Argument 1 passed to AppExceptionsHandler::report() must be an instance of Exception, instance of TypeError given, called in
or an error like this
Uncaught TypeError: Argument 1 passed to App\\Exceptions\\Handler::report() must be an instance of Exception, instance of Error given, called
after upgrading to PHP7, Laravel started throwing this error
the error is in the exception handling — how do I fix it?
without thinking too long, and after trying various methods and tips, I decided to change the framework core, in the file
/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
add
+use Exception;
+use Symfony\Component\Debug\Exception\FatalThrowableError;
in the handleException method of the HandleExceptions class, add this condition
public function handleException($e)
{
+ if (! $e instanceof Exception) {
+ $e = new FatalThrowableError($e);
+ }
+
$this->getExceptionHandler()->report($e);
if ($this->app->runningInConsole())
.....
second option, to do it differently in the same file and the same function
public function handleException($e)
{
if (! $e instanceof Exception) {
$e = new \Exception($e->getMessage()."\n".$e->getTraceAsString(), $e->getCode()); // new FatalThrowableError($e);
}...
this should help
Comments