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
In Laravel 5 you can catch exceptions by editing the render method in app/Exceptions/Handler. php . This will be applied to ANY exception in AJAX requests. If your app is sending out an exception of App\Exceptions\MyOwnException , you check for that instance instead.
By default, the Laravel exception handler will convert exceptions into an HTTP response for you. However, you are free to register a custom rendering closure for exceptions of a given type. You may accomplish this via the renderable method of your exception handler.
Throwable is the base interface for any object that can be thrown via a throw statement, including Error and Exception.
Behind the scenes, Laravel already ignores some types of errors for you, such as exceptions resulting from 404 HTTP "not found" errors or 419 HTTP responses generated by invalid CSRF tokens Try updating your report method to this, this should send an email for every exception, regardless of the type. Link to the docs for reporting exceptions.
This is a common error message that we get when setting up laravel project for the first time. We can easily fix this error by changing the owner of app/storage folder to ‘www-data’ and ensuring the permission is set to 755. Now, let’s discuss how our Support Engineers fix this error. How we fix laravel error in exception handler?
Normally you can use php artisan clear-compiled to remove the compiled class file, but you're trapped in a catch 22 because in order to run the command, Laravel will use... the compiled cache file throwing the error you got. So try removing the file manually, and you should be good to go.
To make things more performant, Laravel caches quite some stuff in /bootstrap/cache. I ran into the same issue before, and removing the /bootstrap/cache/compiled.php might actually resolve this.
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 theException
interface instead ofThrowable
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 theThrowable
interface instead ofException
instances:
use Throwable;
public function report(Throwable $exception);
public function render($request, Throwable $exception);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With