R/try.R

Defines functions try_or_stop_print_pattern

Documented in try_or_stop_print_pattern

### Try to run a capture function. If it fails we wrap the error
### message with a more informative message that also includes the
### generated pattern.
try_or_stop_print_pattern <- function(expr, pat, engine){
  tryCatch(expr, error=function(e){
    stop(
      pat,
      "\nwhen matching pattern above with ",
      engine, " engine, an error occured: ",
      e$message)
  })
}

Try the nc package in your browser

Any scripts or data that you put into this service are public.

nc documentation built on March 25, 2020, 5:10 p.m.