Learn R Programming

xfun (version 0.30)

try_error: Try an expression and see if it throws an error

Description

Use tryCatch() to check if an expression throws an error.

Usage

try_error(expr)

Arguments

expr

An R expression.

Value

TRUE (error) or FALSE (success).

Examples

Run this code
# NOT RUN {
xfun::try_error(stop("foo"))  # TRUE
xfun::try_error(1:10)  # FALSE
# }

Run the code above in your browser using DataLab