deferred_errors_flush: Flush deferred errors

Description Usage Examples

View source: R/defer.R

Description

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.

Usage

1

Examples

 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

reside-ic/defer documentation built on Nov. 5, 2019, 3:06 a.m.