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()
## ---------------------------------------------<!-- %dont -->
## 2: bar(2)
## 1: foo(2)
bar
## Ah, this is the culprit ...
## This will print the stack trace at the time of the error.
options(error = function() traceback(2))
Run the code above in your browser using DataLab