Description Usage Arguments Details Value Examples
try_catch()
is similar to tryCatch()
, except that, by default, errors are
captured and presented using error()
. Messages and warnings are not
captured by this function. In addition, a "finally" expression can be
specified which is evaluated at the end of the call no matter the result.
1 2 3 | try_catch(expr, on_error, finally = NULL)
try_silently(expr)
|
expr |
(expression) The expression to evaluate |
on_error |
(function, optional) A function describing what to do in the
event of a error in the above expression. The function must take a single
argument, which is the |
finally |
(expression, optional) An expression to evaluate at the end of
the call. If missing or |
try_silenty()
is similar to try(..., silently = TRUE)
however if there is
an error it returns NULL
. All messages and warnings are also suppressed.
The result of the evaluated expression
1 2 3 4 5 6 7 8 9 10 | ## Not run:
try_catch(x <- "foo")
try_catch(stop("This is an error"))
try_silently("This is fine")
try_silently(stop("This is an error"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.