Description Usage Arguments Examples
View source: R/catch_condition.R
This function captures a condition object such as a warning or error, to allow for testing components and classes.
1 2 3 | catch_condition(code)
catch_all_conditions(code)
|
code |
code to run that should assert a condition. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | (cond <- catch_condition(stop("catch me.")))
class(cond)
my_fun <- function(){
message("a message")
warning("a warning")
pkg_message("a package message", scope="test")
pkg_warning("a package warning", scope="test")
pkg_error("a package error", scope='test')
}
conditions <- catch_all_conditions(my_fun())
conditions$messages
conditions$warnings
conditions$error # only one error can be caught at a time.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.