Created
August 11, 2020 08:53
-
-
Save Paul-Yuchao-Dong/59c7405b7a20bcb11fdad5b2ebc703ae to your computer and use it in GitHub Desktop.
.Rprofile config to show trace on error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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