Skip to content

Examine error handling features of rlang package #49

@aryoda

Description

@aryoda

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

  • abort
  • warn
  • inform
    to 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:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions