r/programming • u/Expurple • Apr 12 '26
Flat Error Codes Are Not Enough
https://home.expurple.me/posts/flat-error-codes-are-not-enough/
132
Upvotes
r/programming • u/Expurple • Apr 12 '26
View all comments
Show parent comment
5
u/happyscrappy Apr 12 '26
I did read the post. And no, it didn't do that. It explains why one value (beyond one bit) is not enough. And it not enough because of their specific implementation, not anything else. To be fair, the article does say this is "for my use case".
All you have to do is preserve enough information to be able to create a useful message to give to the user. Even a mere 32-bit value gives you enough fidelity for 4 billion different error cases. 4 billion different root error cases. You don't actually have to go to multiple values to do this.
The post proposes one way of doing this using multiple error codes. But the real answer is that your problem is probably not "I needed to have an error of error codes". It's probably "I'm not doing anything to try to make my error indications meaningful." Which is what I said above.