tryCatchLog
tryCatchLog copied to clipboard
Provide condition handling vignette with best practices
E. g.
- how to signal a condition (
signalCondition?) - how to clean-up resources (
finallyoron.exit) - restart types provided by R (
invokeRestart("abort")to "rethrow a caught interrupt condition" to interrupt/exit the running R script)
Focus on the typical use cases and show how to apply tryCatchLog for them...
Henry Lionel's talk "Reducing bewilderment by improving errors" at ERUM 2018 gave some good best practices:
- Error message guidelines: http://style.tidyverse.org/error-messages.html
- Catch and rethrow low-level technical errors with a message that makes sense to the end user (+ sub class it for precise recognition and recovery/fine-grained handling with
tryCatch(exp, this_error = my_handler)andsuppress_warnings("that_warning")) - add additional (meta) data to the condition, e. g. actual values
See rlang::abort and rlang::warn (signature: msg, subclass, mydata, ...)