Raising Classed conditions helps with catching errors. These allow for typing errors as they arise and adding scopes to better catch errors from specific locations.
condition(msg, cond = .conditions, ..., scope = find_scope(),
type = NULL, call = sys.call(1))pkg_error(msg, ..., scope = find_scope(), call = sys.call(1))
pkg_warning(msg, ..., scope = find_scope(), call = sys.call(1))
pkg_message(msg, ..., scope = find_scope(), call = sys.call(1))
The message to convey
The severity of the condition, or what to do; give a 'message' (default), a 'warning', an 'error' or do 'none' and ignore.
Attributes to be added to condition object for condition
,
arguments passed to condition for all others.
A character vector of the scope(s) of the signal. Defaults to the package name but could be longer such as package name, a class name, and a method call. This should be used as a where the error occurred.
Used with scope
and cond
to set the class of the condition object to raise.
This should be a type of error; out of bounds, type mismatch, etcetera.
The call to use to include in the condition.
The condition()
function alone provides a flexible and dynamic way of
producing conditions in code. The functions pkg_error
, pkg_warning
,
and pkg_message
do the same as condition except restricted to errors, warnings,
and messages respectively.