cli_abort {cli} | R Documentation |
These functions let you create error, warning or diagnostic messages with cli formatting, including inline styling, pluralization and glue substitutions.
cli_abort(
message,
...,
call = .envir,
.envir = parent.frame(),
.frame = .envir
)
cli_warn(message, ..., .envir = parent.frame())
cli_inform(message, ..., .envir = parent.frame())
message |
It is formatted via a call to |
... |
Passed to |
call |
The execution environment of a currently running
function, e.g. You only need to supply Can also be For more information about error calls, see Including function calls in error messages. |
.envir |
Environment to evaluate the glue expressions in. |
.frame |
The throwing context. Used as default for
|
n <- "boo" cli_abort(c( "{.var n} must be a numeric vector", "x" = "You've supplied a {.cls {class(n)}} vector." ))
#> Error: #> ! `n` must be a numeric vector #> ✖ You've supplied a <character> vector. #> Run `rlang::last_error()` to see where the error occurred.
len <- 26 idx <- 100 cli_abort(c( "Must index an existing element:", "i" = "There {?is/are} {len} element{?s}.", "x" = "You've tried to subset element {idx}." ))
#> Error: #> ! Must index an existing element: #> ℹ There are 26 elements. #> ✖ You've tried to subset element 100. #> Run `rlang::last_error()` to see where the error occurred.