Created
May 11, 2015 01:58
-
-
Save daattali/c37b00c35bf8b6ed1e5a to your computer and use it in GitHub Desktop.
beepr_error
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
# rasmusab/beepr package is great for telling you when your R code finishes running. | |
# But if the code throws an error, the beep will never come, and you won't know that | |
# it finished running until you visually check. | |
# Solution: change the error handler to a failure beep. | |
# Example | |
foo <- function(success = TRUE) { | |
if (!success) { | |
stop("Error!") | |
} | |
invisible() | |
} | |
foo(); beepr::beep() # this will beep when done | |
foo(FALSE); beepr::beep() # this will never beep | |
# Solution: just add a beep to the error handler | |
old_err <- options(error = function(x) beepr::beep(9)) | |
foo(FALSE); beepr::beep() | |
options(error = old_err$error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment