Hacker News new | ask | show | jobs
Ask HN: Error codes vs. error messages
2 points by zotez 3356 days ago
I'm developing a package in Go and I've attempted to put a custom error message for each and every error condition. However I am now starting to have a problem where a lot of error conditions have the same or similar error message. This is making it very difficult to trace down the code responsible for the error. My question is, what does HN think about using numeric error codes to help identify the source of the error or should I just work really hard on making error messages different each and every time? Any better solution?
1 comments

I think you should have error codes ("enums") all the way and the a way to translate these into error messages. That removes a lot of problems with spelling, changing the error message and interoperability with outers using your package.