Skip to contents

Assert that a condition is true.

Usage

crew_assert(value = NULL, ..., message = NULL, envir = parent.frame())

Arguments

value

An object or condition.

...

Conditions that use the "." symbol to refer to the object.

message

Optional message to print on error.

envir

Environment to evaluate the condition.

Value

NULL (invisibly). Throws an error if the condition is not true.

Examples

crew_assert(1 < 2)
crew_assert("object", !anyNA(.), nzchar(.))
tryCatch(
  crew_assert(2 < 1),
  crew_error = function(condition) message("false")
)
#> false