Skip to content

Instantly share code, notes, and snippets.

@daattali
Created May 11, 2015 01:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daattali/c37b00c35bf8b6ed1e5a to your computer and use it in GitHub Desktop.
Save daattali/c37b00c35bf8b6ed1e5a to your computer and use it in GitHub Desktop.
beepr_error
# 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