R/captureErrors.R

Defines functions captureErrors

captureErrors = function(func, captureList, default = NULL, ...)
{
  res = try(wrapr::DebugFnW(as.name('lastError'), func)(...), silent = T)
  if(exists("lastError", envir = globalenv())){
    assign(x=captureList,
           value = do.call(append,
                           args = list(x=as.name(captureList),
                                       values = list(list(#calling_function = funcName,
                                                          wrapr_data = lastError,
                                                          error_msg = res)))),
           inherits = T)
    do.call(what = rm, args = list(as.name('lastError')), envir = globalenv())
    res = default
  }
  return(res)
}
bplloyd/Core documentation built on May 11, 2017, 2:39 p.m.