sfinktah / repeat-if-exception
PHP functool: repeat function while it throws an exception
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/sfinktah/repeat-if-exception
Requires
- php: ^7.2|^8.0
This package is auto-updated.
Last update: 2025-09-10 14:14:00 UTC
README
use Sfinktah\FuncTools\RepeatIfException;
function throw_exception($arg1, $arg2) {
printf("throw_exception: %s %s\n", $arg1, $arg2);
throw new Exception("throw_exception");
}
Retry 3 times, with 60 seconds delay between each. Pass arguments arg1
and arg2
to function.
By closure
RepeatIfException::call(['GuzzleHttp\\Exception\\'], 60, 3, fn($arg1, $arg2) => throw_exception($arg1, $arg2), 'arg1', 'arg2');
By function name
RepeatIfException::call(['GuzzleHttp\\Exception\\'], 60, 3, 'throw_exception', 'arg1', 'arg2');
By static method name (i think)
RepeatIfException::call(['GuzzleHttp\\Exception\\'], 60, 3, ['class', 'method', 'arg1', 'arg2');
By instance method (i think)
RepeatIfException::call(['GuzzleHttp\\Exception\\'], 60, 3, [$instance, 'method', 'arg1', 'arg2');