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.

deferred_errors_flush()

Examples

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
#> <deferred_errors: 1 error occured: #> - got a negative number: -1>