Skip to content

Commit e122fdc

Browse files
committed
allow providing an onError callable that is called on every error
1 parent c34c68c commit e122fdc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/retry.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
class FailingTooHardException extends \Exception {}
66

7-
function retry($retries, callable $fn)
7+
function retry($retries, callable $fn, callable $onError = null)
88
{
99
beginning:
1010
try {
1111
return $fn();
1212
} catch (\Exception $e) {
13+
if ($onError) {
14+
$onError($e);
15+
}
1316
if (!$retries) {
1417
throw new FailingTooHardException('', 0, $e);
1518
}

0 commit comments

Comments
 (0)