Rev 26856 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{stop}\title{Stop Function Execution}\usage{stop(\dots, call. = TRUE)geterrmessage()}\alias{stop}\alias{geterrmessage}\arguments{\item{\dots}{character vectors (which are pasted together with noseparator), a condition object, or \code{NULL}.}\item{call.}{logical, indicating if the call should become part of theerror message.}}\description{\code{stop} stops execution of the current expression and executesan error action.\code{geterrmessage} gives the last error message.}\details{The error action is controlled by error handlers established withinthe executing code and by the current default error handler set by\code{options(error=)}. The error is first signaled as if using\code{\link{signalCondition}()}. If there are no handlers or if all handlersreturn, then the error message is printed (if\code{options("show.error.messages")} is true) and the default errorhandler is used. The default behaviour (the \code{NULL}error-handler) in interactive use is to return to the top levelprompt or the top level browser, and in non-interactive use to(effectively) call \code{\link{q}("no", status=1, runLast=FALSE}).The default handler stores the error message in a buffer; it can beretrieved by \code{geterrmessage()}. It also stores a trace ofthe call stack that can be retrieved by \code{\link{traceback}()}.Errors will be truncated to \code{getOption("warning.length")}characters, default 1000.}\value{\code{geterrmessage} gives the last error message, as character stringending in \code{"\\n"}.}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\seealso{\code{\link{warning}}, \code{\link{try}} to catch errors and retry,and \code{\link{options}} for setting error handlers.\code{\link{stopifnot}} for validity testing. \code{tryCatch}and \code{withCallingHandlers} can be used to establish custom handlerswhile executing an expression.}\examples{options(error = expression(NULL))# don't stop on stop(.) << Use with CARE! >>iter <- 12if(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}\keyword{environment}\keyword{programming}\keyword{error}