Fork me on GitHub!

condition wercker status codecov.io

R doesn’t come with a built-in constructor function for conditions, but we can easily add one.

(Advanced R, by Hadley Wickham)

Actually, there is simpleCondition(), simpleError() and the like, but they don't allow specifying an additional class. The functions in this package allow it:

library(condition)
cond <- new_error("Something went wrong", class = "oops")
cond
## <oops: Something went wrong>
is.error(cond)
## [1] TRUE

See the vignette for additional details.

Help topics

  • condition(condition-package)
    Create custom conditions
  • Condition(Error, Message, SimpleCondition, SimpleError, SimpleMessage, SimpleWarning, Warning)
    Predefined condition classes
  • is.condition(is.error, is.message, is.warning)
    Check if the condition is of the appropriate type
  • new_condition(new_error, new_message, new_warning)
    Create a condition

Vignettes

Dependencies

  • Imports: R6
  • Suggests: testthat, knitr, rmarkdown

Authors