Skip to content

Instantly share code, notes, and snippets.

@nathan-russell
Created February 23, 2017 18:27
Show Gist options
  • Save nathan-russell/52255e2470feb1d49e551ad7d28f3792 to your computer and use it in GitHub Desktop.
Save nathan-russell/52255e2470feb1d49e551ad7d28f3792 to your computer and use it in GitHub Desktop.
f <- function(x) if (x == "France") stop("error") else cat("success\n")
for (country in c("France","USA", "Germany")) {
tryCatch({
f(country)
}, error = function(e) {
cat("failed on ", country, "\n")
})
}
# failed on France
# success
# success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment