assert_soft: Assert (soft)

warn_if_notR Documentation

Assert (soft)

Description

Raises an assertion warning when any(expr) is false.

Raises an assertion warning when all(expr) is true.

Usage

warn_if_not(
  expr,
  warn_message = NULL,
  warn_class = NULL,
  call = rlang::caller_call(),
  env = rlang::caller_env(),
  print_expr = NULL,
  ...
)

warn_if(
  expr,
  warn_message = NULL,
  warn_class = NULL,
  call = rlang::caller_call(),
  env = rlang::caller_env(2L),
  print_expr = NULL,
  ...
)

Arguments

expr

<expression> a logical expression to test.

warn_message

<string> a message to be displayed when assertion fails.

warn_class

<character> the class name/s for the warning.

call

The execution environment of a currently running function, e.g. call = caller_env(). The corresponding function call is retrieved and mentioned in error messages as the source of the error.

You only need to supply call when throwing a condition from a helper function which wouldn't be relevant to mention in the message.

Can also be NULL or a defused function call to respectively not display any call or hard-code a code to display.

env

<environment> the environment for substituted dots and print_expr. Has no effect if dots and print_expr are already quosures.

print_expr

<expression> a diffused expression for altering the error message. Defaults to rlang::as_quosure(substitute(expr), rlang::caller_env())

...

<any> values used in evaluating glue expressions, for the error message.


qfes/tidyassert documentation built on March 19, 2022, 7:18 a.m.