condition {pkgcond} | R Documentation |
Raise a mutable and classed condition.
Description
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.
Usage
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))
Arguments
msg |
The message to convey |
cond |
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 |
scope |
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. |
type |
Used with |
call |
The call to use to include in the condition. |
Details
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.