Description Usage Arguments Value Examples
These are function that actually evaluate expression and "catch" the conditions. catch_expr()
evaluates an expression, catching and handling the conditions it raises according to whatever catchr plans are specified. make_catch_fn()
is a function factory that returns a function that behaves like catch_expr()
with the plans already specified.
Plans can be passed in as output from make_plans()
or as input that follows the same format as the input to make_plans()
.
1 2 3 | catch_expr(expr, ..., .opts = NULL)
make_catch_fn(..., .opts = NULL)
|
expr |
the expression to be evaluated |
... |
a catchr plan as made by |
.opts |
The options to be used for the plans (generally passed in using |
For catch_expr()
: The value of the evaluated expression if there isn't an error and if the plans don't force an exit. If getOption("catchr.bare_if_possible")
is FALSE
(or if any conditions have been collect), it will return a named list, with the "value" element containing the value of the evaluated expression and sublists containing any collected conditions.
For make_catch_fn()
A function that catches conditions for expressions the same way catch_expr()
would, but with the plans already specified.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | warner <- function() {
warning("Suppress this!")
"done!"
}
compiled_warning_plans <- make_plans(warning = muffle)
warning_catcher <- make_catch_fn(warning = muffle)
warning_catcher2 <- make_catch_fn(compiled_warning_plans)
# `results` 1-4 are equivalent
results1 <- catch_expr(warner(), warning = muffle)
results2 <- warning_catcher(warner())
results3 <- catch_expr(warner(), compiled_warning_plans)
results4 <- warning_catcher2(warner())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.