Laravel error Declaration of App\Exceptions\Handler::report(Throwable $exception)

Viewed 30193

I'm using Laravel 6 and getting the following error when deploying to a shared host running PHP 7.3:

App\Exceptions\Handler::report(Throwable $exception)

Declaration of App\Exceptions\Handler::report(Throwable $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Exception $e) in /home/kb2hm3y8r4wm/public_html/laravel.supremeanimation.com/app/Exceptions/Handler.php on line 8

1 Answers

I think the error you're getting is due to changes on Laravel 7 (not 6), as you can see on Laravel 7 upgrade guide. Check this:

  • For Laravel < 7:

    The report and render methods of your application's App\Exceptions\Handler class should accept instances of the Exception interface instead of Throwable instances:

    use Exception;
    
    public function report(Exception $exception);
    public function render($request, Exception $exception);
    
  • For Laravel >= 7:

    The report and render methods of your application's App\Exceptions\Handler class should accept instances of the Throwable interface instead of Exception instances:

    use Throwable;
    
    public function report(Throwable $exception);
    public function render($request, Throwable $exception);
    
Related