From: Vincent Vanwaelscappel Date: Mon, 21 Aug 2023 15:35:49 +0000 (+0200) Subject: wip #6202 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=cf827ca8f28a5684b5e67957522378f533407a22;p=cubist_util.git wip #6202 @0.25 --- diff --git a/src/PHP.php b/src/PHP.php index 3a86f42..bed218a 100644 --- a/src/PHP.php +++ b/src/PHP.php @@ -77,4 +77,16 @@ class PHP if ($return) return $export; else echo $export; } + + public static function retryOnError(callable $callback, $attempts = 3) + { + try { + return call_user_func($callback); + } catch (\Exception $e) { + if ($attemps > 0) { + return self::retryOnError($callback, $attempts - 1); + } + throw $e; + } + } }