explore using classed errors in rlang's abort, warn, inform
- Dominant language
- C++
- Stars
- 607
- Forks
- 67
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 1
Description
https://rlang.r-lib.org/reference/abort.html
This allows for classed errors to be passed to the user as well as doing nicer printing of the error messages.
The user then might be able to control what happens with the error, e.g.,
```r
# Give a class to the error:
abort("Something bad happened", "somepkg_bad_error")
# This will allow your users to handle the error selectively
tryCatch(
somepkg_function(),
somepkg_bad_error = function(err) {
warn(conditionMessage(err)) # Demote the error to a warning
NA # Return an alternative value
}
)
```
as it states in the documentation
```
# Unhandled errors are saved automatically by `abort()` and can be
# retrieved with `last_error()`.
```
Contributor guide
Assessment
This issue has not been assessed yet.