Learn R Programming

R.oo (version 1.9.8)

abort: Aborts the current expression call

Description

Aborts the current expression call and returns to the top level prompt/browser without signalling a condition.

Usage

## S3 method for class 'default':
abort(message, call=NULL, ...)

Arguments

message
A character string giving the abort message.
call
An optional call expression.
...
Not used.

Value

  • Returns nothing.

See Also

throw(). stop().

Examples

Run this code
foo <- function() {
  tryCatch({
    stop("Woops!")
  }, error = function(ex) {
    cat("An error was caught: ", ex$message, "\n", sep="")
  })
  cat("Continuing...\n");
}

bar <- function() {
  tryCatch({
    abort("Woops!")
  }, error = function(ex) {
    cat("An error was caught: ", ex$message, "\n", sep="")
  })
  cat("This message will never be displayed...\n");
}

# An error generated by stop() can be caught
foo()

# ...which is not possible when using abort()
bar()

Run the code above in your browser using DataLab