lib/rubber/util.rb
def retry_on_failure(*exception_list)
      opts = exception_list.last.is_a?(Hash) ? exception_list.pop : {}
      opts = {:retry_count => 3}.merge(opts)
      retry_count = opts[:retry_count]
      begin
        yield
      rescue *exception_list
        if retry_count > 0
          retry_count -= 1
          Rubber.logger.info "Exception, trying again #{retry_count} more times"
          sleep opts[:retry_sleep].to_i if opts[:retry_sleep] 
          retry
        else
          Rubber.logger.error "Too many exceptions...re-raising"
          raise
        end
      end
    end
# execute the given block, retrying only when one of the given exceptions is raised
execute the given block, retrying only when one of the given exceptions is raised
execute the given block retrying only when one of the given exceptions is raised
def retry_on_failure(*exception_list)
      opts = exception_list.last.is_a?(Hash) ? exception_list.pop : {}
      opts = {:retry_count => 3}.merge(opts)
      retry_count = opts[:retry_count]
      begin
        yield
      rescue *exception_list
        if retry_count > 0
          retry_count -= 1
          Rubber.logger.info "Exception, trying again #{retry_count} more times"
          sleep opts[:retry_sleep].to_i if opts[:retry_sleep] 
          retry
        else
          Rubber.logger.error "Too many exceptions...re-raising"
          raise
        end
      end
    end
def retry_on_failure ( * exception_list ) opts = exception_list . last . is_a? ( Hash ) ? exception_list . pop : { } opts = { :retry_count => 3 } . merge ( opts ) retry_count = opts [ :retry_count ] begin yield rescue * exception_list if retry_count > 0 retry_count -= 1 Rubber . logger . info "Exception, trying again #{retry_count} more times" sleep opts [ :retry_sleep ] . to_i if opts [ :retry_sleep ] retry else Rubber . logger . error "Too many exceptions...re-raising" raise end end end
execute the given block, retrying only when one of the given exceptions is raised
execute the given block retrying only when one of the given exceptions is raised
exception_list