Closed gittadm closed 3 years ago
Hey there,
Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to report back and I'll gladly help you out and re-open this issue.
Thanks!
I don't know why this issue was closed, but i got the same RequestException even I don't chain ->throw method on Http client. Obviously the documentation is not accurate at the moment.
@driesvints we've also faced this issue today, and just as @baceto90 says. In the laravel documentation, HTTP client facade shows it will not explicit throw exception before you use throw method. But retry method was broke this awareness.
I think it will make a lot of cufuse when people use it. (and this behavior will be aware easily, because retry failed is not common scenario)
Please consider it is a bug or refactor need. Thanks.
I thought the point of not throwing an exception was to avoid the need of a try catch and handling it with $response->failed(). But we still need a try catch because not all exceptions are caught...
I just got bit by this bug in Laravel 10. Retry() causes undocumented/inconsistent behavior. Why is this bug closed??
For anyone landing here looking for a resolution, the retry method has a throw parameter that you can set to stop the retry throwing an exception
Description:
According to documentation https://laravel.com/docs/8.x/http-client#error-handling :
Unlike Guzzle's default behavior, Laravel's HTTP client wrapper does not throw exceptions on client or server errors (400 and 500 level responses from servers).
But code like this
$response = Http::withToken(config('api.auth_token')) ->retry(API::RETRY_TIMES, API::RETRY_SLEEP_MILLISECONDS) ->timeout(API::TIMEOUT_SECONDS) ->post(API::getFullURL($url), $data);
throw RequestException for 422 answer code
Steps To Reproduce: