Skip to content

Instantly share code, notes, and snippets.

@Paul-Yuchao-Dong
Created August 11, 2020 08:53
Show Gist options
  • Save Paul-Yuchao-Dong/59c7405b7a20bcb11fdad5b2ebc703ae to your computer and use it in GitHub Desktop.
Save Paul-Yuchao-Dong/59c7405b7a20bcb11fdad5b2ebc703ae to your computer and use it in GitHub Desktop.
.Rprofile config to show trace on error
options(error = function() {
calls <- sys.calls()
if (length(calls) >= 2L) {
sink(stderr())
on.exit(sink(NULL))
cat("Backtrace:\n")
calls <- rev(calls[-length(calls)])
for (i in seq_along(calls)) {
cat(i, ": ", deparse(calls[[i]], nlines = 1L), "\n", sep = "")
}
}
if (!interactive()) {
q(status = 1)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment