Skip to content

Commit d3a001c

Browse files
authored
Fix Http::retry so that throw is respected for call signature Http::retry([1,2], throw: false) (#684)
* Fix Http::retry so that throw is respected for call signature Http::retry([1,2], throw: false) * chore: Remove unused Throwable import and update throw_if and throw_unless functions --------- Co-authored-by: Deeka Wong <[email protected]>
1 parent 099ce07 commit d3a001c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/PendingRequest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,15 @@ public function send(string $method, string $url, array $options = [])
897897
$response->throw($this->throwCallback);
898898
}
899899

900-
if ($attempt < $this->tries && $shouldRetry) {
900+
$potentialTries = is_array($this->tries) // @phpstan-ignore-line
901+
? count($this->tries) + 1
902+
: $this->tries;
903+
904+
if ($attempt < $potentialTries && $shouldRetry) {
901905
$response->throw();
902906
}
903907

904-
if ($this->tries > 1 && $this->retryThrow) {
908+
if ($potentialTries > 1 && $this->retryThrow) {
905909
$response->throw();
906910
}
907911
}

0 commit comments

Comments
 (0)