as_result | R Documentation |
result
type, choosing between success
and failure
based on the outcome of the expression.Use as_result
on expressions whose outcomes are not known in advance or not
safe to be examined. The expression will be evualted immediately and wrapped
in success
if it produces a value or failure
if it produces an
error. If the expression produces a warning, it will be wrapped in
success
or failure
depending on the fail_on_warning
argument.
as_result(.expr, detect_warning = TRUE, fail_on_warning = TRUE)
.expr |
expression to evaluate |
detect_warning |
logical, whether to detect warnings; note
|
fail_on_warning |
logical, whether to treat warnings as |
result
object of subclass success
or failure
as_result(42)
as_result(1 + 1)
stopper <- as_result(stop("This is my error message"))
is_failure(stopper)
value(stopper)
as_result(warning("You've been warned")) |> is_success()
as_result(warning("You've been warned"), fail_on_warning = FALSE) |> value()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.