Within a defer_errors
block, flush any deferred
errors, turning them into realised errors. If no deferrable
errors have occurred, this function has no effect.
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 | check_positive <- function(x) {
if (x < 0) {
deferrable_error(paste("got a negative number:", x))
}
}
err <- tryCatch(
defer::defer_errors({
check_positive(-1)
defer::deferred_errors_flush()
check_positive(-2)
}),
error = identity)
err
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.