Learn R Programming

erratum (version 2.2.0)

bash: Take a Bash

Description

Equivalent to tryCatch().

Usage

bash(expr, e = NULL, w = NULL)

Arguments

expr

Expression to run, passed to tryCatch().

e, w

An object of class Error or Warning as returned by e() or w().

Examples

Run this code
# NOT RUN {
safe_log <- function(x){
 result <- bash(log(x))
 
 if(is.e(result))
   stop(result$stop())

 return(result)
} 

if(interactive())
 safe_log("a")

# }

Run the code above in your browser using DataLab