dot-stop_cant_coerce: Abort with a standardized "can't coerce" message

.stop_cant_coerceR Documentation

Abort with a standardized "can't coerce" message

Description

Abort with a standardized "can't coerce" message

Usage

.stop_cant_coerce(
  from_class,
  to_class,
  x_arg,
  call,
  additional_msg = NULL,
  message_env = call,
  parent = NULL,
  ...
)

Arguments

from_class

⁠(length-1 character)⁠ The class of the object that failed coercion.

to_class

⁠(length-1 character)⁠ The target class for the coercion.

x_arg

⁠(length-1 character)⁠ An argument name for x. The automatic value will work in most cases, or pass it through from higher-level functions to make error messages clearer in unexported functions.

call

(environment) The execution environment to mention as the source of error messages.

additional_msg

⁠(length-1 character)⁠ Optional, additional cli-formatted messages.

message_env

(environment) The execution environment to use to evaluate variables in error messages.

parent

A parent condition, as you might create during a rlang::try_fetch(). See rlang::abort() for additional information.

...

Additional parameters passed to cli::cli_abort() and on to rlang::abort().

Value

This function is called for its side effect of throwing an error and does not return a value.


stbl documentation built on Nov. 5, 2025, 6:02 p.m.