assertionError {assertive.base} | R Documentation |
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
.
Note
These objects behave the same as the standard-issue simpleError
,
simpleWarning
, and simpleMessage
objects from base-R. The
extra class allows you to provide custom handling for assertions inside
tryCatch
.
Examples
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
}
}
)
[Package assertive.base version 0.0-9 Index]