Could you clarify the section on condition classes when testing for errors?
EllaKaye opened this issue · 0 comments
Hello,
The R Packages (2e) book is fantastic and has been enormously helpful as I'm developing a new package. Having read it now all the way through, there is just one section that left me a bit confused, in 14.5.2 on testing errors. Would it be possible to clarify the part about the class of a condition? It would be really good to have an example here (or earlier in the book) of how to attach a custom class to a condition, when writing a function, ready for use in expect_error()
. (I did figure it out, but it took digging through the source code of stringr, then rlang, plus a chapter of Advanced R and a couple of other blog posts to get there).
(If this counts as a contribution, then I assign the copyright of said contribution to Hadley Wickham).