- message
The message to display, formatted as a bulleted
list. The first element is displayed as an alert bullet
prefixed with !
by default. Elements named "*"
, "i"
, "v"
,
"x"
, and "!"
are formatted as regular, info, success,
failure, and error bullets respectively. See Formatting messages with cli
for more about bulleted messaging.
If a message is not supplied, it is expected that the message is
generated lazily through cnd_header()
and cnd_body()
methods. In that case, class
must be supplied. Only inform()
allows empty messages as it is occasionally useful to build user
output incrementally.
If a function, it is stored in the header
field of the error
condition. This acts as a cnd_header()
method that is invoked
lazily when the error message is displayed.
- class
Subclass of the condition.
- ...
Additional data to be stored in the condition object.
If you supply condition fields, you should usually provide a
class
argument. You may consider prefixing condition fields
with the name of your package or organisation to prevent name
collisions.
- 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.
For more information about error calls, see Including function calls in error messages.
- body, footer
Additional bullets.
- trace
A trace
object created by trace_back()
.
- parent
Supply parent
when you rethrow an error from a
condition handler (e.g. with try_fetch()
).
If parent
is a condition object, a chained error is
created, which is useful when you want to enhance an error with
more details, while still retaining the original information.
If parent
is NA
, it indicates an unchained rethrow, which
is useful when you want to take ownership over an error and
rethrow it with a custom message that better fits the
surrounding context.
Technically, supplying NA
lets abort()
know it is called
from a condition handler. This helps it create simpler
backtraces where the condition handling context is hidden by
default.
For more information about error calls, see Including contextual information with error chains.
- use_cli_format
Whether to format message
lazily using
cli if available. This results in
prettier and more accurate formatting of messages. See
local_use_cli()
to set this condition field by default in your
package namespace.
If set to TRUE
, message
should be a character vector of
individual and unformatted lines. Any newline character "\\n"
already present in message
is reformatted by cli's paragraph
formatter. See Formatting messages with cli.
- .inherit
Whether the condition inherits from parent
according to cnd_inherits()
and try_fetch()
. By default,
parent conditions of higher severity are not inherited. For
instance an error chained to a warning is not inherited to avoid
unexpectedly catching an error downgraded to a warning.
- .internal
If TRUE
, a footer bullet is added to message
to let the user know that the error is internal and that they
should report it to the package authors. This argument is
incompatible with footer
.
- .file
A connection or a string specifying where to print the
message. The default depends on the context, see the stdout
vs
stderr
section.
- .frame
The throwing context. Used as default for
.trace_bottom
, and to determine the internal package to mention
in internal errors when .internal
is TRUE
.
- .trace_bottom
Used in the display of simplified backtraces
as the last relevant call frame to show. This way, the irrelevant
parts of backtraces corresponding to condition handling
(tryCatch()
, try_fetch()
, abort()
, etc.) are hidden by
default. Defaults to call
if it is an environment, or .frame
otherwise. Without effect if trace
is supplied.
- .subclass
This argument
was renamed to class
in rlang 0.4.2 for consistency with our
conventions for class constructors documented in
https://adv-r.hadley.nz/s3.html#s3-subclassing.
- .frequency
How frequently should the warning or message be
displayed? By default ("always"
) it is displayed at each
time. If "regularly"
, it is displayed once every 8 hours. If
"once"
, it is displayed once per session.
- .frequency_id
A unique identifier for the warning or
message. This is used when .frequency
is supplied to recognise
recurring conditions. This argument must be supplied if
.frequency
is not set to "always"
.
- id
The identifying string of the condition that was supplied
as .frequency_id
to warn()
or inform()
.