report_checkmate_assertions {zephyr} | R Documentation |
Report collection of assertions
Description
Improved reporting of an AssertCollection
created with the
checkmate::makeAssertCollection()
using cli::cli_abort()
instead of
checkmate::reportAssertions()
in order to provide a more
informative error message.
The function is intended to be used inside a function that performs assertions on its input arguments.
Usage
report_checkmate_assertions(
collection,
message = "Invalid input(s):",
.envir = parent.frame()
)
Arguments
collection |
|
message |
|
.envir |
The |
Value
invisible(TRUE)
Examples
add_numbers <- function(a, b) {
collection <- checkmate::makeAssertCollection()
checkmate::assert_numeric(x = a, add = collection)
checkmate::assert_numeric(x = b, add = collection)
report_checkmate_assertions(collection)
return(a + b)
}
add_numbers(1, 2)
try(add_numbers(1, "b"))
try(add_numbers("a", "b"))
[Package zephyr version 0.1.2 Index]