This help topic is for R version 1.7.1. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/stop.html
stop {base}R Documentation

Stop Function Execution

Description

stop stops execution of the current expression, prints the message given as its argument, then executes an error action.

geterrmessage gives the last error message.

Usage

stop(..., call. = TRUE)
geterrmessage()

Arguments

...

character vectors (which are pasted together with no separator) or NULL.

call.

logical, indicating if the call should become part of the error message.

Details

The error action is controlled by the current error handler set by options(error=). The default behaviour (the NULL error-handler) in interactive use is to return to the top level prompt, and in non-interactive use to (effectively) call q("no", status=1, runLast=FALSE).

Errors will be truncated to getOption("warning.length") characters, default 1000.

Value

geterrmessage gives the last error message, as character string ending in "\n".

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth \& Brooks/Cole.

See Also

warning, try to catch errors and retry, and options for setting error handlers. stopifnot for validity testing.

Examples

options(error = expression(NULL))# don't stop on stop(.)  << Use with CARE! >>

iter <- 12
if(iter > 10) stop("too many iterations")

tst1 <- function(...) stop("dummy error")
tst1(1:10,long,calling,expression)

tst2 <- function(...) stop("dummy error", call. = FALSE)
tst2(1:10,long,calling,expression,but.not.seen.in.Error)

options(error = NULL)# revert to default

[Package base version 1.7.1 ]