Retry function X times before stopping in error

retry.func(expr, isError = function(x) "try-error" %in% class(x),
  maxErrors = 5, sleep = 0)

Arguments

expr

The function to try running

maxErrors

The number of times to retry the function

sleep

How long to wait before retrying the function call

Value

retval returns the results of the function call

Details

Retry function X times before stopping in error

Examples

# NOT RUN {
dap <- retry.func(
  ncdf4::nc_open('https://thredds.daac.ornl.gov/thredds/dodsC/ornldaac/1220/mstmip_driver_global_hd_climate_lwdown_1999_v1.nc4'),
  maxErrors=10,
  sleep=2)
# }# NOT RUN {
# }