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, prints the
     message given as its argument, then executes an error action.

     `geterrmessage' gives the last error message.

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

 message: a character vector (of length 1) 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 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').

_V_a_l_u_e:

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

_S_e_e _A_l_s_o:

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

_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

