
stop
stops execution of the current expression and executes
an error action. geterrmessage
gives the last error message.
stop(..., call. = TRUE, domain = NULL)
geterrmessage()
gettext
. If NA
, messages will
not be translated.geterrmessage
gives the last error message, as a character string
ending in "\n"
.
options(error=)
. The error is first signaled as if using
signalCondition()
. If there are no handlers or if all handlers
return, then the error message is printed (if
options("show.error.messages")
is true) and the default error
handler is used. The default behaviour (the NULL
error-handler) in interactive use is to return to the top level
prompt or the top level browser, and in non-interactive use to
(effectively) call q("no", status = 1, runLast = FALSE
).
The default handler stores the error message in a buffer; it can be
retrieved by geterrmessage()
. It also stores a trace of
the call stack that can be retrieved by traceback()
. Errors will be truncated to getOption("warning.length")
characters, default 1000.
If a condition object is supplied it should be the only argument, and further arguments will be ignored, with a warning.
warning
, try
to catch errors and retry,
and options
for setting error handlers.
stopifnot
for validity testing. tryCatch
and withCallingHandlers
can be used to establish custom handlers
while executing an expression. gettext
for the mechanisms for the automated translation
of messages.
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, longcalling, expression, but.not.seen.in.Error)
options(error = NULL) # restore to default
Run the code above in your browser using DataLab