nicklasos
9/23/2014 - 8:52 AM

retry

retry

<?php

function retry($retries, callable $fn)
{
  beginning:
  try {
    return $fn();
  } catch (\Exception $e) {
    if (!$retries) {
      throw new \Exception();
    }
    $retries--;
    goto beginning;
  }
}