\HeaderA{stop}{Stop Function Execution}{stop}
\aliasA{geterrmessage}{stop}{geterrmessage}
\keyword{environment}{stop}
\keyword{programming}{stop}
\keyword{error}{stop}
\begin{Description}\relax
\code{stop} stops execution of the current expression and executes
an error action.

\code{geterrmessage} gives the last error message.
\end{Description}
\begin{Usage}
\begin{verbatim}
stop(..., call. = TRUE, domain = NULL)
geterrmessage()
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] character vectors (which are pasted together with no
separator), a condition object, or \code{NULL}.
\item[\code{call.}] logical, indicating if the call should become part of the
error message.
\item[\code{domain}] see \code{\LinkA{gettext}{gettext}}. If \code{NA}, messages will
not be translated.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The error action is controlled by error handlers established within
the executing code and by the current default error handler set by
\code{options(error=)}.  The error is first signaled as if using
\code{\LinkA{signalCondition}{signalCondition}()}.  If there are no handlers or if all handlers
return, then the error message is printed (if
\code{options("show.error.messages")} is true) and the default error
handler is used.  The default behaviour (the \code{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 \code{\LinkA{q}{q}("no", status=1, runLast=FALSE}).
The default handler stores the error message in a buffer; it can be
retrieved by \code{geterrmessage()}.  It also stores a trace of
the call stack that can be retrieved by \code{\LinkA{traceback}{traceback}()}.

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

An attempt is made to coerce other types of inputs to character vectors.
\end{Details}
\begin{Value}
\code{geterrmessage} gives the last error message, as a character string
ending in \code{"\bsl{}n"}.
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{warning}{warning}}, \code{\LinkA{try}{try}} to catch errors and retry,
and \code{\LinkA{options}{options}} for setting error handlers.
\code{\LinkA{stopifnot}{stopifnot}} for validity testing.  \code{tryCatch}
and \code{withCallingHandlers} can be used to establish custom handlers
while executing an expression.

\code{\LinkA{gettext}{gettext}} for the mechanisms for the automated translation
of messages.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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)# revert to default
\end{ExampleCode}
\end{Examples}

