WeTalkive
WeTalkive

Reputation: 1

Upgrade from laravel 5 to laravel 5.5 caused an error Argument 1 passed to App\Exceptions\Handler::report()

We are trying to upgrade our laravel 5.0 project to the latest version of laravel (laravel 5.5 would be also fine) to support php7.1. When we are running composer install laravel gives the error below:

[Symfony\Component\Debug\Exception\FatalErrorException] Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instanc e of Error given, called in C:\xampp7\htdocs\V.E.K. Lexmond\vendor\laravel\framework\src\Illuminate\Foundation\Boot strap\HandleExceptions.php on line 73 and defined in C:\xampp7\htdocs\V.E.K. Lexmond\app\Exceptions\Handler.php:25 Stack trace: #0 C:\xampp7\htdocs\V.E.K. Lexmond\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.ph p(73): App\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown

What would be the reason of the this error? We hope anyone got a solution for our problem.

Thank you in advance!

WeTalkive

Upvotes: 0

Views: 1814

Answers (3)

WeTalkive
WeTalkive

Reputation: 1

<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
    'Illuminate\Contracts\Http\Kernel',
    'App\Http\Kernel'
);

$app->singleton(
    'Illuminate\Contracts\Console\Kernel',
    'App\Console\Kernel'
);

$app->singleton(
    'Illuminate\Contracts\Debug\ExceptionHandler',
    'App\Exceptions\Handler'
);

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;

Upvotes: 0

WeTalkive
WeTalkive

Reputation: 1

Handler.php

use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler {

/**
 * A list of the exception types that should not be reported.
 *
 * @var array
 */
protected $dontReport = [
    'Symfony\Component\HttpKernel\Exception\HttpException'
];

/**
 * Report or log an exception.
 *
 * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
 *
 * @param  \Exception  $e
 * @return void
 */
public function report(Exception $e)
{
    return parent::report($e);
}

/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $e
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $e)
{
    return parent::render($request, $e);
}

}

Upvotes: 0

Roger Rodriguez Texido
Roger Rodriguez Texido

Reputation: 303

Can you post what you have in bootstrap/app.php?

also check if you have this in that file

$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class

);

Upvotes: 0

Related Questions