traceback(data=last.dump, print=T)
"names"
attribute of
data
gives the character form of the
calls.
This object is created by a call to
dump.frames
or
dump.calls
,
typically because one of them has been specified as option
error
.
TRUE
, the call stack is printed to the screen.
print = TRUE
, that is,
prints a list of the function calls in the process of being evaluated
at a particular time.
When
traceback
is called, it decides which of two possible call stacks
it should print: the current call stack or one saved on a previous
error. If
traceback
is called from a top-level expression or is
given an explicit
data
argument, it will print the saved call stack.
Otherwise, it prints the currently active call stack.
Use
traceback
first when an error occurs that is mystifying.
It tells you what function created the error and the calling sequence that led
to that function call.
If this is not enough information to discover the cause of the error, then use
debugger
,
browser
, or
trace
.
When using
browser
,
traceback()
is often useful to determine
how
browser
was called.
This is particularly true when
browser
was invoked as a result
of an interrupt or tracing action.
Two techniques useful for preventing errors during loops or other
long calculations from losing all intermediate results are to:
(1) save intermediate
results using
assign
(use
immediate=T
),
and (2) trap errors using
try
.
f1 <- function(x) { y <- x+4; f2(y)} f2 <- function(x) weird.variable + x f1(5) Error in call to "f2": Object "weird.variable" not found Dumped traceback() 3: f2(y) 2: f1(5) 1: