lower <- function(a, s) {warning(traceCall(s, mesremove=FALSE), "stupid berry warning: ", a+10); a}
upper <- function(b, skip=0) lower(b+5, skip)
upper(3)
# Since 2022-05-04, use tmessage / twarning / tstop instead!
upper(3, skip=1) # traceCall skips last level (R3: warning, R4.1: .makeMessage, R4.2: lapply)
upper(3, skip=6) # now the stack is empty
d <- tryStack(upper("four"), silent=TRUE)
inherits(d, "try-error")
cat(d)
lower <- function(a,...) {warning(traceCall(1, prefix="in ", suffix=": "),
"How to use traceCall in functions ", call.=FALSE); a}
upper(3)
Run the code above in your browser using DataLab