-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Higher-level exception types #2098
Comments
I think some nuance and discussion is required on which exceptions actually need custom types, and which ones will just end up being unnecessary additional lines of code that no one actually ever catches and handles. I agree that we overuse some exception types (like In general, sticking to the built-in concrete exceptions as much as possible seems to be the most efficient way to go about this, and makes the most sense, to me. In the example above and based on the built-in exceptions documentation:
I don't think custom exceptions for these examples would be helpful. With that said, I do agree there may be exceptions types/classes that need to be re-evaluated in the code, and I think we should need an actual reason/use to add custom exceptions (i.e., say if we need to differentiate between exception types and catch a specific one that may be raised simultaneously to others, or the built-in exceptions just aren't appropriate at all). Edit: also note that exceptions are usually raised with an associated text message, and this message is where the actual helpful/specific error information is located, in terms of informing the user of what went wrong. In my understanding, it is not the job of the exception type/class to necessarily be very informative or thorough, that is the job of the exception message. |
So
|
@seanpearsonuk yes, I believe differentiating by the exception message (e.g., check But I don't know what this potential custom exception would be called, and I also don't know whether it would realistically ever be used. I would expect these basic configuration exceptions will usually be resolved manually and not automatically (also considering they can be differentiated by the message as well, so the custom type may not be needed at all even for automatic solutions, as you noted). |
Hi @raph-luc just one point for clarification: regarding 'check |
Design and use higher-level exceptions that specify the actual issue rather than emitting bland, lower-level built-in exception types.
E.g., fluent_container.py
The text was updated successfully, but these errors were encountered: