cli_abort {cli}R Documentation

Signal an error, warning or message with a cli formatted message

Description

These functions let you create error, warning or diagnostic messages with cli formatting, including inline styling, pluralization and glue substitutions.

Usage

cli_abort(message, ..., .envir = parent.frame())

cli_warn(message, ..., .envir = parent.frame())

cli_inform(message, ..., .envir = parent.frame())

Arguments

message

It is formatted via a call to cli_bullets().

...

Passed to rlang::abort(), rlang::warn() or rlang::inform().

.envir

Environment to evaluate the glue expressions in.

Details

n <- "boo"
cli_abort(c(
        "{.var n} must be a numeric vector",
  "x" = "You've supplied a {.cls {class(n)}} vector."
))

cli-abort.svg

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}."
))

cli-abort-2.svg


[Package cli version 3.1.1 Index]