% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{retry}
\alias{retry}
\title{A wrapper around \code{try} that retries on failure}
\usage{
retry(
  expr,
  envir = parent.frame(),
  retries = 5,
  exponentialDecayBase = 1.3,
  silent = TRUE,
  exprBetween = NULL,
  messageFn = message
)
}
\arguments{
\item{expr}{An expression to run, i.e., \code{rnorm(1)}, similar to what is passed to \code{try}}

\item{envir}{The environment in which to evaluate the quoted expression, default
to \code{parent.frame(1)}}

\item{retries}{Numeric. The maximum number of retries.}

\item{exponentialDecayBase}{Numeric > 1.0. The delay between
successive retries will be \code{runif(1, min = 0, max = exponentialDecayBase ^ i - 1)}
where \code{i} is the retry number (i.e., follows \code{seq_len(retries)})}

\item{silent}{Logical indicating whether to \code{try} silently.}

\item{exprBetween}{Another expression that should be run after a failed attempt
of the \code{expr}. This should return a named list, where the names indicate the object names
to update in the main expr, and the return value is the new value. (previous versions allowed
a non-list return, but where the final line had to be an assignment operator,
specifying what object (that is used in \code{expr}) will be updated prior to running
the \code{expr} again. For backwards compatibility, this still works).}

\item{messageFn}{A function for messaging to console. Defaults to \code{message}}
}
\value{
As with \code{try}, so the successfully returned \code{return()} from the \code{expr} or a \code{try-error}.
}
\description{
This is useful for functions that are "flaky", such as \code{curl}, which may fail for unknown
reasons that do not persist.
}
\details{
Based on \url{https://github.com/jennybc/googlesheets/issues/219#issuecomment-195218525}.
}
