stop                  package:base                  R Documentation

_S_t_o_p _F_u_n_c_t_i_o_n _E_x_e_c_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     'stop' stops execution of the current expression and executes an
     error action.

     'geterrmessage' gives the last error message.

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

     ...: character vectors (which are pasted together with no
          separator), a condition object, or 'NULL'.

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

_D_e_t_a_i_l_s:

     The error action is controlled by error handlers established
     within the executing code and by the current default error handler
     set by '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.

_V_a_l_u_e:

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

_R_e_f_e_r_e_n_c_e_s:

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

_S_e_e _A_l_s_o:

     '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.

_E_x_a_m_p_l_e_s:

     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

