Skip to contents

Checks a condition and stops execution with a custom error message if the condition is not met. The error message is formed by concatenating the additional arguments.

Usage

stopifnot_with_message(condition, message, ...)

Arguments

condition

Logical. The condition to be evaluated.

message

Character. The base message to be used if the condition is FALSE.

...

Additional message parts to be concatenated for the error message.

Value

This function does not return a value. It stops execution with an error message if the condition is FALSE.

Examples

if (FALSE) { # \dontrun{
  x <- 5
  stopifnot_with_message(x > 10, "x must be greater than 10")
} # }