traceback                package:base                R Documentation

_P_r_i_n_t _C_a_l_l _S_t_a_c_k_s

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

     By default, 'traceback()' prints the call stack of the last
     uncaught error, i.e., the sequence of calls that lead to the
     error. This is useful when an error occurs with an unidentifiable
     error message.  It can also be used to print arbitrary lists of
     deparsed calls.

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

     traceback(x = NULL)

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

       x: 'NULL' (default), or a list or pairlist of deparsed calls.

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

     The stack of the last uncaught error is stored as a list of
     deparsed calls in '.Traceback', which 'traceback' prints in a
     user-friendly format.  The stack of deparsed calls always contains
     all function calls and (as from R 2.3.0) all foreign function
     calls (such as '.Call'): if profiling is in progress it will
     include all other calls to primitive functions.

     Errors which are caught _via_ 'try' or 'tryCatch' do not generate
     a traceback, so what is printed is the call sequence for the last
     uncaught error, and not necessarily the last error.

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

     'traceback()' returns nothing, but prints the deparsed call stack
     deepest call first.  The calls may print on more than one line,
     and the first line for each call is labelled by the frame number. 
     The number of lines printed per call can be limited by setting
     'options(deparse.max.lines)'.

_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.

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

     foo <- function(x) { print(1); bar(2) }
     bar <- function(x) { x + a.variable.which.does.not.exist }
     ## Not run: 
     foo(2) # gives a strange error
     traceback()
     ## End(Not run)
     ## 2: bar(2)
     ## 1: foo(2)
     bar
     ## Ah, this is the culprit ...

