RConsortium / wishlist

A wishlist of idea from the ISC and community
29 stars 0 forks source link

Working group to standardize error (condition) classes #6

Open gaborcsardi opened 7 years ago

gaborcsardi commented 7 years ago

While I was listening to @mllg's talk about https://github.com/mllg/checkmate at useR, I started wondering why R packages and base R do not use condition classes to report more specific errors. I guess one reason is that people just don't know about them. I know httr uses this already, and I think more packages should, it would be easier to treat different kinds of errors. E.g. when reading from a database, if I get a database connection error, I might try again a bit later, if I get a query syntax error, I won't.

I chatted to @mllg after the talk, and he liked the idea of creating different kinds of errors for checkmate. E.g. a generic assertion_error, more specific out_of_bounds_error, null_error, etc., details to be worked out.

Then it also occurred to me that it would be bad if people started defining error types in their packages using the same or similar names and slightly different semantics, and it would make sense to create a package that just defines the condition types. So @mllg created this: https://github.com/mllg/conditions

I think that ideally these (or similar) classes belong to base R. It would make sense to create a working group to work out the class hierarchy for errors and other conditions. It would be especially great if R core could be involved in this.

tslumley commented 7 years ago

Would also be useful if the standard error types had standard translations -- would need to involve the translation teams.

If I recall correctly, there was a plan a long time ago to create a full class hierarchy of conditions based on the Python ones, and it just didn't get done.

jimhester commented 7 years ago

I actually just got finished writing a draft proposal for this very thing https://gist.github.com/jimhester/4e8cf6dd9788dd21b2427bdbec1edf16

Of note here is the table of number of errors (not using condition classes) currently in base R for R and C code

type error warning message
R 2937 664 306
C 3278 654 NA
gaborcsardi commented 7 years ago

@jimhester Great work!

ltierney commented 7 years ago

This has been on my TODO list for a long time but hasn't made it to the top. I'm happy to help. The Common Lisp condition hierarchy is a natural starting point. One last missing feature in the condition handling support is continuable errors; there are some reasonable pressing issues that could benefit from having that so it sill probably get added fairly soon. SHould be orthogonal to the hierarchy design though.