A wrapper on err() that sets the subclass to be 'chk_error'.
Usage
abort_chk(..., n = NULL, tidy = TRUE, call = rlang::caller_call(2))
Value
Throws an error of class 'chk_error'.
Arguments
...
Multiple objects that are converted to a string using
paste0(..., collapse = '').
n
The value of n for converting sprintf-like types.
tidy
A flag specifying whether capitalize the first character and add a missing period.
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 call when throwing a condition from a
helper function which wouldn't be relevant to mention in the
message.
Can also be NULL or a defused function call to
respectively not display any call or hard-code a code to display.
try(abort_chk("x must be NULL"))
try(abort_chk("`x` must be NULL"))
try(abort_chk("there %r %n problem value%s", n = 1))
try(abort_chk("there %r %n problem value%s", n = 1.5))