R: Catch a condition

catch_cnd {rlang} | R Documentation

## Catch a condition

### Description

This is a small wrapper around `tryCatch()` that captures any condition signalled while evaluating its argument. It is useful for debugging and unit testing.

### Usage

    catch_cnd(expr)

### Arguments

`expr` | Expression to be evaluated with a catch-all condition handler.

### Value

A condition if any was signalled, `NULL` otherwise.

### Examples

    catch_cnd(10)
    catch_cnd(abort("an error"))
    catch_cnd(cnd_signal("my_condition", .msg = "a condition"))

[Package rlang version 0.2.2 Index]