Learn R Programming

targets (version 0.4.1)

tar_traceback: Get a target's traceback

Description

If a target ran with error = "workspace" and errored out, tar_traceback() returns its traceback. The workspace file must exist. For more information, see tar_workspace().

Usage

tar_traceback(
  name,
  envir = NULL,
  packages = NULL,
  source = NULL,
  characters = getOption("width")
)

Arguments

name

Symbol, name of the target whose workspace to read.

envir

Deprecated in targets > 0.3.1 (2021-03-28).

packages

Logical, whether to load the required packages of the target.

source

Logical, whether to run _targets.R to load user-defined global object dependencies into envir. If TRUE, then envir should either be the global environment or inherit from the global environment.

characters

Positive integer. Each line of the traceback is shortened to this number of characters.

Value

Character vector, the traceback of a failed target if it exists.

See Also

Other debug: tar_workspaces(), tar_workspace()

Examples

Run this code
# NOT RUN {
if (identical(Sys.getenv("TAR_LONG_EXAMPLES"), "true")) {
tar_dir({ # tar_dir() runs code from a temporary directory.
tmp <- sample(1)
tar_script({
  tar_option_set(error = "workspace")
  list(
    tar_target(x, "loaded"),
    tar_target(y, stop(x))
  )
}, ask = FALSE)
try(tar_make())
tar_traceback(y, characters = 60)
})
}
# }

Run the code above in your browser using DataLab