Evaluating Rich Errors: use cases from existing projects #498
Replies: 6 comments 7 replies
I'd like to point out that this doesn't solve the problem. C++ is the worst example of this, where the same language effectively has different dialects in different teams, even though everything is available out of the box to all of them. |
|
Thanks for making this study! The 'callsite' sections specifically are very interesting to me, and I felt they were missing in the initial KEEP. It looks like the conclusion of this study is that the operators are essentially never used? There are seven examples with |
|
Do you have plans to look at some non-android (e.g. server side, maybe spring) projects too? |
As a human, I like this, but I think it's the kind of thing that would trip up AI agents. |
|
I think the clarification about how rich errors are more meant to replace sealed result hierarchies than all exceptions is very helpful and important, and I hope something along those lines makes it into the docs when the feature is released. |
|
I think the main question is just why encourage developers to use this pattern, which from the use cases cited doesn't seem better than exceptions and is often clearly worse e.g. there's lots of manual wrapping and propagating going on, and in most cases a simple try/catch block would be equally or more concise. The only real benefit seems to be restoring checking in the type system, but a new take on checked exceptions in Kotlin (which I'd love to see) would fix that too.In fact the very first example cited, Signal's NetworkResult class, states specifically that it only exists because Kotlin doesn't have checked exceptions! The final example also shows the risks of this approach. That an operation is in progress isn't actually an error, so error types are being abused as a general union type in that case. But it's not called out as an abuse, in fact it's called out as a good way to use the feature. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The document evaluates how Rich Errors (KEEP-0462) could be used in a few projects today, analyzing both declaration and use sites. It comes somewhat late: some of this was already analyzed in the first version of the Rich Errors proposal (link), but we now have more concrete examples. Plus, since the design has changed quite a lot, we had to revisit how the feature could be applied in practice and now publish our findings.
Feel free to challenge the document or share your own examples of where Rich Errors could (or couldn’t) help in your domain.
Read the full design notes: Evaluating Rich Errors in the Wild
All reactions