berryFunctions (version 1.19.1)

traceCall: call stack of a function

Description

trace the call stack e.g. for error checking and format output for do.call levels

Usage

traceCall(
  skip = 0,
  prefix = "\nCall stack: ",
  suffix = "\n",
  vigremove = TRUE
)

Arguments

skip

Number of levels to skip in traceback

prefix

Prefix prepended to the output character string. DEFAULT: "\nCall stack: "

suffix

Suffix appended to the end of the output. DEFAULT: "\n"

vigremove

Logical: remove call created using devtools::build_vignettes()? DEFAULT: TRUE

Value

Character string with the call stack

See Also

tryStack, checkFile for example usage

Examples

Run this code
# NOT RUN {
lower <- function(a, s) {warning(traceCall(s), "stupid berry warning: ", a+10); a}
upper <- function(b, skip=0) lower(b+5, skip)
upper(3)
upper(3, skip=1) # traceCall skips last level (warning)
upper(3, skip=4) # 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 DataCamp Workspace