this post was submitted on 09 Jun 2025
89 points (94.9% liked)
Programmer Humor
36501 readers
167 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Not a rust dev, rather c++, but just to understand, how should a type be named if it is used to carry information about an error?
Os this an issue with the language, similar to C where you don't have namespaces, and thus need to call everything acmecorp_error_v5 or something like that?
Prefix the name with what it's for. For example, I've previously got a
SoundFontError
from opening soundfont file."Error" is already used by
std::error::Error
. It might not be imported by the code that imports your error type, but I think it's better to give it distinct name.The other thing is that you might want to use more than one library. Typical imports at the top of the file might look like this:
If both libraries named their error enums just "Error", the collision could be worked around, but it's an unnecessary extra step:
or if you want to avoid renaming:
If the screenshot had followed conventions, the message would say something like this:
I see, thanks for the time you took explaining this. I think it is more a cultural difference then in how patterns evolved.