Created
January 24, 2017 10:23
-
-
Save jonovik/9fd3ef556f2780920dc30b40a6150003 to your computer and use it in GitHub Desktop.
This file contains 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
# Save state on error to facilitate debugging | |
postmortem <- function() { | |
# SAVE TO SOMEWHERE BOTH YOU AND THE RUNNING PROGRAM HAVE ACCESS | |
save.image("postmortem.RData") | |
# Skip irrelevant levels of traceback, see the "If x is numeric" part of ?traceback. | |
traceback(3) | |
stop() | |
} | |
options(error=postmortem) | |
# Your code goes here | |
x <- 42 | |
# Example of code that causes an error | |
glm() | |
# Profit: You can now, even in a new session, | |
# load(postmortem.RData) | |
# and you will see x = 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment