Description Usage Arguments Details Value Author(s) See Also Examples
This function accepts an existing R function as its first argument and returns a new R function with enhanced error and warning logging capabilities.
1 |
FUN |
The function to "errorize". If you are making a drop-in replacement, include the namespace (see Details). |
fileSuffix |
A vector of length one. The suffix to append to the .Rds filename if there is an error or warning. If |
stopOnError |
Logical. If the function errors out, do you want to stop the script (the default) or issue a warning and proceed. |
onErrorReturn |
If |
... |
Additional arguments to |
If you encounter an error or warning, an "errorized" function will save the error or warning, the time at which the error or warning occurred, the function that threw the error, and all the objects entering the "errorized" function in a list.
If you want to create a drop-in replacement of an existing R function (i.e. create a new function of the same name as an existing function in the global environment), you'll need to include the namespace in the call to errorize
in the form namespace::function
.
A function identical to the function passed to errorize
but with enhanced error and warning logging capabilities.
Ian K. Kyle
saveRDS
, readRDS
for reading the saved error or warning information back in
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Not run:
lm <- errorize(stats::lm)
data("cars")
lm(speed ~ dist, data = cars) # works
lm(speed ~ missing_variable, data = cars) # this errors out and saves the data to a .Rds file
# read the saved data back in (timestamp on filename will change based on when the above is run)
er <- readRDS('./lm_error_1478361734.Rds')
# use do.call to recreate the error
do.call(er$fxn, er$arglst)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.