1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/conditions.R
\name{assertionError}
\alias{assertionError}
\alias{assertionWarning}
\alias{assertionMessage}
\title{Condition classes}
\usage{
assertionError(message, call = NULL, predicate_name = NULL)
assertionWarning(message, call = NULL, predicate_name = NULL)
assertionMessage(message, call = NULL, predicate_name = NULL)
}
\arguments{
\item{message}{A string describing the problem.}
\item{call}{A call describing the source of the condition.}
\item{predicate_name}{A string naming the predicate that was called when the
condition occured.}
}
\value{
An object of class \code{assertionError}, \code{assertionWarning}, or
\code{assertionMessage}.
}
\description{
Error, warning, and message classes derived from their simple equivalents.
}
\note{
These objects behave the same as the standard-issue \code{simpleError},
\code{simpleWarning}, and \code{simpleMessage} objects from base-R. The
extra class allows you to provide custom handling for assertions inside
\code{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
}
}
)
}
|