rst_abort

0th

Percentile

Jump to the abort restart

The abort restart is the only restart that is established at top level. It is used by R as a top-level target, most notably when an error is issued (see abort()) that no handler is able to deal with (see with_handlers()).

Usage
rst_abort()
See Also

rst_jump(), abort() and cnd_abort().

Aliases
  • rst_abort
Examples
# NOT RUN {
# The `abort` restart is a bit special in that it is always
# registered in a R session. You will always find it on the restart
# stack because it is established at top level:
rst_list()

# You can use the `above` restart to jump to top level without
# signalling an error:
# }
# NOT RUN {
fn <- function() {
  cat("aborting...\n")
  rst_abort()
  cat("This is never called\n")
}
{
  fn()
  cat("This is never called\n")
}
# }
# NOT RUN {
# The `above` restart is the target that R uses to jump to top
# level when critical errors are signalled:
# }
# NOT RUN {
{
  abort("error")
  cat("This is never called\n")
}
# }
# NOT RUN {
# If another `abort` restart is specified, errors are signalled as
# usual but then control flow resumes with from the new restart:
# }
# NOT RUN {
out <- NULL
{
  out <- with_restarts(abort("error"), abort = function() "restart!")
  cat("This is called\n")
}
cat("`out` has now become:", out, "\n")
# }
Documentation reproduced from package rlang, version 0.1.6, License: GPL-3

Community examples

Looks like there are no examples yet.