ERRVL {statnet.common} | R Documentation |
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-error
s.
Usage
ERRVL(...)
Arguments
... |
Expressions to be tested; usually outputs of
|
Value
The first argument that is not a try-error
. Stops
with an error if all are.
Note
This function uses lazy evaluation, so, for example ERRVL(1, stop("Error!"))
will never evaluate the stop
call and will
not produce an error, whereas ERRVL(try(solve(0)), stop("Error!"))
would.
In addition, all expressions after the first may contain a .
,
which is substituted with the try-error
object returned by the
previous expression.
See Also
Examples
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: ", .)))
## End(Not run)
[Package statnet.common version 4.9.0 Index]