assertive.base (version 0.0-7)

assertionError: Condition classes

Description

Error, warning, and message classes derived from their simple equivalents.

Usage

assertionError(message, call = NULL, predicate_name = NULL)

assertionWarning(message, call = NULL, predicate_name = NULL)

assertionMessage(message, call = NULL, predicate_name = NULL)

Arguments

message

A string describing the problem.

call

A call describing the source of the condition.

predicate_name

A string naming the predicate that was called when the condition occured.

Value

An object of class assertionError, assertionWarning, or assertionMessage.

Examples

Run this code
# NOT RUN {
tryCatch(
  assert_all_are_true(FALSE), 
  error = function(e) 
  {
    if(inherits(e, "assertionCondition"))
    {
      # Handle assertions
      message("This is an assertion condition.")
      
      # Handle assertions cause by a specific predicate
      if(e$predicate_name == "is_true")
      {
      }
    } else
    {
      # Handle other error types
    }
  }
)
# }

Run the code above in your browser using DataLab