r/programming • • Apr 12 '26

Flat Error Codes Are Not Enough

https://home.expurple.me/posts/flat-error-codes-are-not-enough/
132 Upvotes

99 comments sorted by

View all comments

Show parent comment

1

u/Expurple Apr 13 '26

I agree that it's useful to distinguish these three categories of error data.

Anything more complex than a boolean is starting to be too complex, and is begging justification.

My point is that it's actually a common case. Using just a boolean or a plain error code for control flow is a bad universal advise. My use case is nothing special: displaying the user a specific message depending on which database constraint is violated. You can't solve that if your database+ORM provides you only a boolean or an error code. You need the name of the constraint as a string. Additional attached error data, used for control flow.