f <- function(x) log(x)
g <- protect(f)
f(0) # -Inf
g(0, fail.value=-999) # -999
f <- function(x) {
if ( x < 1 )
stop("dummmy error")
x
}
g <- protect(f)
f(0) # error
g(0, fail.value=-999) # -999
Run the code above in your browser using DataLab