Skip to content

Instantly share code, notes, and snippets.

@eachanjohnson
Created October 28, 2016 15:01
Show Gist options
  • Save eachanjohnson/7cff7aa6ff0deac818456d5299eb469b to your computer and use it in GitHub Desktop.
Save eachanjohnson/7cff7aa6ff0deac818456d5299eb469b to your computer and use it in GitHub Desktop.
Error handling binary operator in R
`%except%` <- function (try.expression, catch.expression) {
tryCatch(try.expression,
error=function(e) {
if ( inherits(catch.expression, 'function') ) {
catch.expression(e)
} else {
catch.expression
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment