Learn R Programming

statnet.common (version 4.3.0)

ERRVL: Return the first argument passed (out of any number) that is not a try-error (result of try encountering an error.

Description

This function is inspired by NVL, and simply returns the first argument that is not a try-error, raising an error if all arguments are try-errors.

Usage

ERRVL(...)

Arguments

Expressions to be tested; usually outputs of try.

Value

The first argument that is not a try-error. Stops with an error if all are.

See Also

try, inherits

Examples

Run this code
# NOT RUN {
print(ERRVL(1,2,3)) # 1
print(ERRVL(try(solve(0)),2,3)) # 2
print(ERRVL(1, stop("Error!"))) # No error

# }
# NOT RUN {
# Error:
print(ERRVL(try(solve(0), silent=TRUE),
            stop("Error!")))

# Error with an elaborate message:
print(ERRVL(try(solve(0), silent=TRUE),
            stop("Stopped with an error: ", .)))
# }

Run the code above in your browser using DataLab