assert: Terminates the execution with an error message if the given...

View source: R/rutils.R

assertR Documentation

Terminates the execution with an error message if the given conditional statement is FALSE

Description

Terminates the execution with an error message if the given conditional statement is FALSE

Usage

assert(
  flag,
  err_msg = "Assertion Error !",
  err_src = paste(deparse(sys.calls()[[max(sys.nframe() - 1, 1)]]), collapse = "")
)

Arguments

flag

A boolean: Condition to be checked

err_msg

A character string: Message to be displayed

Examples

x = 1
assert(x > 1, "Argument x can not be greater than 1")

Error in assert(x > 1, "Argument x can not be greater than 1") :
  Argument x can not be greater than 1


genpack/gener documentation built on March 14, 2023, 9:52 a.m.