mercredi 27 septembre 2017

Cannot throw objects that do not implement Throwable

I am using Laravel 5.5. There is following class

vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php

with Method Name: buildException

In, Laravel 5.4, I was able to return JSON in this method like below.

protected function buildException($key, $maxAttempts)
{
    $retryAfter = $this->getTimeUntilNextRetry($key);
    $headers = $this->getHeaders(
        $maxAttempts,
        $this->calculateRemainingAttempts($key, $maxAttempts, $retryAfter),
        $retryAfter
    );
    return response()->json('429 Too many requests');
}

When I try to return JSON in above method using Laravel 5.5, it says

Cannot throw objects that do not implement Throwable

Now sure , how could I return JSON in Laravel 5.5 for above method



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire