Created
October 19, 2015 13:34
-
-
Save hadley/0631b3b54da339acb79e to your computer and use it in GitHub Desktop.
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
msg <- function(..., prob = 0.25) { | |
if (runif(1) > prob) { | |
return(invisible()) | |
} | |
messages <- c(...) | |
message(sample(messages, 1)) | |
} | |
encourage <- function() { | |
msg( | |
"Everyone makes mistakes.", | |
"Have you tried googling the error message?", | |
"Frustration is a typical part of programming.", | |
"Sometimes carefully reading the error is helpful.", | |
"Take a deep breath and smile. You'll feel better!" | |
) | |
} | |
discourage <- function() { | |
msg( | |
"THE BUG IS IN YOU!", | |
"Your code is jolly obfuscatory.", | |
"Try again.", | |
"Why did you think that would work?!", | |
"*SIGH*" | |
) | |
} | |
# Pick your poison | |
options(error = encourage) | |
log("a") | |
#> Error in log("a") : non-numeric argument to mathematical function | |
#> Have you tried googling the error message? | |
options(error = discourage) | |
log("a") | |
#> Error in log("a") : non-numeric argument to mathematical function | |
#> THE BUG IS IN YOU! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few quotes from R-help:
Documented behaviour is never a bug.
You are the one claiming there is an issue, so the onus is on you to tell us.
We can write the help and manuals for you, but it is your responsibility to do your own homework.
Beyond this, I cannot help.