is.error | R Documentation |
Does a given expression return an error? Useful for tests where you want to make sure your function throws an error.
is.error(expr, tell = FALSE, force = FALSE)
expr |
Expression to be tested for returning an error |
tell |
Logical: Should the error message be printed via |
force |
Logical: Should an error be returned if the expression is not an error? DEFAULT: FALSE |
TRUE/FALSE
Berry Boessenkool, berry-b@gmx.de, May 2016
stop
, try
, inherits
is.error( log(3) )
is.error( log("a") )
is.error( log(3), tell=TRUE )
is.error( log("a"), tell=TRUE )
stopifnot( is.error( log("a") ) ) # or shorter:
is.error( log("a"), force=TRUE)
# is.error( log(3), force=TRUE)
stopifnot(is.error( is.error(log(3), force=TRUE) ))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.