powered by
Use tryCatch() to check if an expression throws an error.
tryCatch()
try_error(expr)
TRUE (error) or FALSE (success).
TRUE
FALSE
An R expression.
xfun::try_error(stop("foo")) # TRUE xfun::try_error(1:10) # FALSE
Run the code above in your browser using DataLab