format_error {cli} | R Documentation |
Format an error, warning or diagnostic message
Description
You can then throw this message with stop()
or rlang::abort()
.
Usage
format_error(message, .envir = parent.frame())
format_warning(message, .envir = parent.frame())
format_message(message, .envir = parent.frame())
Arguments
message |
It is formatted via a call to |
.envir |
Environment to evaluate the glue expressions in. |
Details
The messages can use inline styling, pluralization and glue substitutions.
n <- "boo" stop(format_error(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.
len <- 26 idx <- 100 stop(format_error(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.
See Also
These functions support inline markup.
Other functions supporting inline markup:
cli_abort()
,
cli_alert()
,
cli_blockquote()
,
cli_bullets_raw()
,
cli_bullets()
,
cli_dl()
,
cli_h1()
,
cli_li()
,
cli_ol()
,
cli_process_start()
,
cli_progress_along()
,
cli_progress_bar()
,
cli_progress_message()
,
cli_progress_output()
,
cli_progress_step()
,
cli_rule
,
cli_status_update()
,
cli_status()
,
cli_text()
,
cli_ul()
,
format_inline()
[Package cli version 3.6.3 Index]