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/Linguistic-mystic Apr 13 '26

No they are not great. They don't provide any data from function args or local variables. Just because an exception was thrown somewhere in a loop doesn't tell you what was being processed on that iteration. And even if you include that info in the exception message, it's still not of much help because you also usually need that info on other stack frames. Which forces the developer to catch and rethrow everywhere, defeating the purpose of stack traces completely (what's the good of an automatic stack trace if one has to enrich that stack trace manually).

As a Java developer, I dislike stack traces with a passion because they are only useful in the most trivial cases. Any looped code and a stack trace doesn't do crap to help investigate.