R: Signal a condition object

cnd_signal {rlang} | R Documentation

## Signal a condition object

### Description

The type of signal depends on the class of the condition:

- A message is signalled if the condition inherits from `"message"`. This is equivalent to signalling with `inform()` or `base::message()`.

- A warning is signalled if the condition inherits from `"warning"`. This is equivalent to signalling with `warn()` or `base::warning()`.

- An error is signalled if the condition inherits from `"error"`. This is equivalent to signalling with `abort()` or `base::stop()`.

- An interrupt is signalled if the condition inherits from `"interrupt"`. This is equivalent to signalling with `interrupt()`.

Use `cnd_type()` to determine the type of a condition.

### Usage

    cnd_signal(cnd, .cnd, .mufflable)

### Arguments

`cnd` | A condition object (see `cnd()`).
`.cnd, .mufflable` | These arguments are deprecated.

### Lifecycle

- `.cnd` has been renamed to `cnd` and is deprecated as of rlang 0.3.0.

- The `.mufflable` argument is deprecated as of rlang 0.3.0 and no longer has any effect. Non-critical conditions are always signalled with a muffle restart.

- Creating a condition object with `cnd_signal()` is deprecated as of rlang 0.3.0. Please use `signal()` instead.

### See Also

`abort()`, `warn()` and `inform()` for creating and signalling structured R conditions. See `with_handlers()` for establishing condition handlers.

### Examples

    # The type of signal depends on the class. If the condition
    # inherits from "warning", a warning is issued:
    cnd <- warning_cnd("my_warning_class", message = "This is a warning")
    cnd_signal(cnd)

    # If it inherits from "error", an error is raised:
    cnd <- error_cnd("my_error_class", message = "This is an error")
    try(cnd_signal(cnd))

[Package rlang version 0.4.0 Index]