Function wrapper to capture errors and warnings for storing
errorSaver.RderrorSaver wraps functions to capture error and warning outputs that would noramlly be emitted to the console can can't be saved. useful for using in apply or loop, here used to collect the warnings issued by readr functions which issue warnings to the console but we want to collect those warnings If there are no errors and no warnings, the regular function result is returned If there are warnings or errors, returns a list with $warn and $err elements this method breaks down if the result
Examples
if (FALSE) { # \dontrun{
log.errors <- errorSaver(log)
log.errors("a")
log.errors(1)
read_csv_with_warnings <- errorSaver(readr::read_csv)
# read_google_sheet_with_spec<-function(gurl, has_description_row = FALSE, )
testfile = "/Users/billspat/tmp/df.csv"
row_1 = strsplit(readLines(testfile , 1), ',')[[1]]
df2 = readr::read_csv(file = "/Users/billspat/tmp/df.csv", col_names = spec.df$col_name, col_types = paste0(substr(spec.df$col_type, 1, 1), collapse = ''))
} # }