tryCatchLog icon indicating copy to clipboard operation
tryCatchLog copied to clipboard

Provide condition handling vignette with best practices

Open aryoda opened this issue 7 years ago • 1 comments

E. g.

  • how to signal a condition (signalCondition?)
  • how to clean-up resources (finally or on.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...

aryoda avatar Jul 29 '18 07:07 aryoda

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) and suppress_warnings("that_warning"))
  • add additional (meta) data to the condition, e. g. actual values

See rlang::abort and rlang::warn (signature: msg, subclass, mydata, ...)

aryoda avatar Oct 22 '18 18:10 aryoda