Skip to contents

This function tries to execute expr and returns a string with the error message if the execution failed. Additionally, warnings are suppressed.

Usage

try_silent(expr)

Arguments

expr

[expression]
An R expression to be evaluated.

Value

Either the value of expr or in case of a failure an object of class fail, which contains the error message.

Details

This function is a wrapper for try.

Examples

try_silent(1 + 1)
#> [1] 2
try_silent(1 + "1")
#> [1] "Error in 1 + \"1\" : non-numeric argument to binary operator\n"
#> attr(,"class")
#> [1] "fail"