failwith: Fail with specified value.

Description Usage Arguments Value See Also Examples

View source: R/failwith.r

Description

Modify a function so that it returns a default value when there is an error.

Usage

1
failwith(default = NULL, f, quiet = FALSE)

Arguments

default

default value

f

function

quiet

all error messages be suppressed?

Value

a function

See Also

try_default

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
f <- function(x) if (x == 1) stop("Error!") else 1
## Not run: 
f(1)
f(2)

## End(Not run)

safef <- failwith(NULL, f)
safef(1)
safef(2)

sctyner/dplyr050 documentation built on May 17, 2019, 2:22 p.m.