Learn R Programming

SimDesign (version 0.3)

check_error: Check if object contains an error and stop flow

Description

Check if the supplied object, which has previously been wrapped in a try function, contains an error. If so, this function will throw an error to stop the workflow.

Usage

check_error(...)

Arguments

...
objects that have been returned from a try call

Examples

Run this code
fun <- function(x) x + 1

res <- try(fun(1), silent = TRUE)
check_error(res) # no error thrown

res <- try(fun('this'), silent = TRUE)
check_error(res) # throws error

# multiple error check
res2 <- try(fun('that'), silent = TRUE)
check_error(res, res2)

Run the code above in your browser using DataLab