Functions for creating and handling custom Entrata-specific conditions, including errors, warnings, and messages.
entrata_abort(): creates a condition representing an error and when thrown, aborts execution.entrata_warn(): creates a condition representing a warning conditionentrata_inform(): creates a condition representing a message condition
These functions wrap cli::cli_abort(), cli::cli_warn(), and cli::cli_inform() respectively,
adding entratar-specific context and class names (entrata_*) to the condition objects for
downstream handling and identification.
Usage
entrata_abort(
msg = NULL,
cls = NULL,
...,
parent = NULL,
call = rlang::caller_env(),
.envir = parent.frame()
)
entrata_warn(msg = NULL, cls = NULL, ..., .envir = parent.frame())
entrata_inform(msg = NULL, cls = NULL, ..., .envir = parent.frame())Arguments
- msg
Character string or vector containing the message to be displayed. This gets passed to
cli::cli_bullets()allowing forcli's custom formatting,glueinterpolation, inline markup syntax, and other features.- cls
Optional character vector of additional classes to assign to the condition.
- ...
Passed to
rlang::abort(),rlang::warn()orrlang::inform().- call
The execution environment of a currently running function, e.g.
call = caller_env(). The corresponding function call is retrieved and mentioned in error messages as the source of the error.You only need to supply
callwhen throwing a condition from a helper function which wouldn't be relevant to mention in the message.Can also be
NULLor a defused function call to respectively not display any call or hard-code a code to display.For more information about error calls, see Including function calls in error messages.
- .envir
Environment to evaluate the glue expressions in.
Value
These functions do not return values, but are used for their side effects, namely
creating and signaling conditions. The entrata_abort() function will stop
execution, while entrata_warn() & entrata_inform() will allow execution
to proceed.
Details
The condition class hierarchy is structured like so:
where <entrata_condition> is the base class for all entratar conditions
and sits on top of the existing rlang and base R condition classes.
For example, an entrata error thrown without any additional custom class added
to it using entrata_abort() will have the following classes:
[1] "entrata_error" "entrata_condition" "rlang_error" "error" "condition"
This allows for filtering and handling of Entrata-specific conditions while still being compatible with the broader R condition system.
See also
Conditions:
entrata_abort_check()
Examples
if (FALSE) { # \dontrun{
entrata_abort("This is a entratar error.")
# catch a condition and check its classes
err <- rlang::catch_cnd(entrata_abort("Error Message"))
class(err)
# catch a warning and check its classes
wrn <- rlang::catch_cnd(entrata_warn("Warning Message"))
class(wrn)
# catch a message and check its classes
msg <- rlang::catch_cnd(entrata_inform("Message"))
class(msg)
} # }
