Silences a stbl error with the specified subclass. Other errors
(including other stbl errors) are not caught and propagate normally. See
the documentation of each stabilize_*() or to_*() function for the types
of errors it throws.
Usage
ignore_stbl_error(expr, subclass = character())Arguments
- expr
An expression to evaluate.
- subclass
(
character) The subclass(es) of thestblerror to ignore or replace. Combined with"stbl-error"to form the class name to intercept. For example,c("coerce", "character")catches errors of classstbl-error-coerce-character(stabilize_chr()),c("coerce")catches anystbl-error-coerceerror, andcharacter()(the default) catches anystblerror.
Value
The result of expr if no matching error is thrown, or NULL
if a matching stbl error is caught.
Examples
ignore_stbl_error(to_chr(data.frame()), subclass = c("coerce", "character"))
#> NULL
ignore_stbl_error(to_chr("hello"), subclass = c("coerce", "character"))
#> [1] "hello"
# Omit subclass to catch any stbl error
ignore_stbl_error(to_chr(data.frame()))
#> NULL