Examine error handling features of rlang package
See the excellent eRum 2018 presentation:
Reducing bewilderment by improving errors | Lionel Henry
Among the many unusual features of the R language, the condition system is probably one of the most obscure. While it is mainly used for exception handling, it is much more powerful and general. This presentation will get advanced R programmers up to speed on the difference between messages and printed output, the difference between exiting and inplace handlers, how does condition muffling work (e.g. suppressWarnings() and suppressMessages()), how to implement error recovery, and how to use error objects to make unit testing more robust and to pass useful metadata to error handlers.
Slides: https://www.dropbox.com/s/fi5fswytwatw1kk/condition-erum.pdf
Video: https://www.youtube.com/watch?v=-v1tp41kizk&t=0s&list=PLUBl0DoLa5SAo_XRnkQA5GtEORg9K7kMh&index=12
See esp. the functions
abortwarninformto enrich conditions with a subclass and data which allows more precise condition reporting (see slides 24 + 25)... or a parent condition (chained errors, see slide 37)...
Chained errors... parent errors... to catch low-level technical errors and rethrow them with a message that makes sense to end users... (slides 36 + 37)
Subclassing for fine-grained error handling: Slide 26
Nice backtrails formatting (with visual code indention in case of multiple code lines)...
See also:
- https://github.com/r-lib/rlang
- https://cran.r-project.org/web/packages/rlang/index.html