-
Notifications
You must be signed in to change notification settings - Fork 286
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
Reconsider exception throwing policy #488
Comments
This is a thoughtful and interesting topic. I'm up to my neck in other stuff at the moment. Let's discuss this next week. I personally have never liked exceptions and prefer to return a status code from every function. Almost everybody disagrees with me and likes exceptions! You are quite correct in observing that we've been adding exceptions. All of this started with the fuzzed files. I don't recall adding new error types in years gone by. |
I am one of these guys who @clanmills mentioned: I normally use exceptions in my code, but I try to just use them for truly exceptional situations. In general I share your worries about the abuse of exceptions, and probably in many cases we can just continue parsing the files and taking default values for the missing fields, or assigning "UNKNOWN" values to them. However, I do not think we can address an issue like this one for the full code base in one go. IMHO, the only sane way of doing this, is to keep this mindset for the future and apply iterative changes as we refactor some parts of the code. |
Just to stress this out, I was not intending to blame anyone! Especially since I have been very much guilty of throwing exceptions left, right and center.
I definitely agree, this is not something that can be easily done. The purpose of this issue was merely to ask for everyone's opinion on the matter and potentially to formulate a new policy that we can follow in the future. |
I'm going to close this. I'm going through all open issues and either closing them or assigning them milestone:v1.00. I think the effort required to reach v1.00 is possible with the contributors we have available. However I don't think an open-ended matter deserves to consume our limited resources. |
tl;dr; Imho we throw too many exceptions and should instead make the code more robust.
Since I have started contributing to exiv2, I have seen a steady increase in the amount of exceptions that we throw from the code (mainly as quick fixes to circumvent issues in fuzzed files) and I am unsure whether that is such a good thing. To illustrate what I mean, take a look at #180, especially at the changes to the test suite. A lot of the fuzzed files that were causing exceptions in the pre-#180 code were now no longer throwing exceptions and instead parsed the fuzzed file (kind-of ok) and instead printed warnings to stderr.
I am afraid, that if we continue the current trend of throwing exceptions for every problem that we find, then we'll be in trouble in the future: The code will be harder to use by users of the library, as they'll have to catch exceptions and find ways how to report them to the user (which is quite hard for generic errors like
kerCorruptedMetadata
). Also, I have the feeling, that we are currently using exceptions as a "short-cut": instead of fixing the code to be more robust, we just throw an exception and the thing is "fixed". However, that's tactical programming and a bad idea in the long term (unless we want more technical debt).Therefore I propose the following policy for exceptions for discussion:
This has imho the following advantages:
HEAD
, we won't be seeing reports from them until a RC/release, thereby increasing our workload.The text was updated successfully, but these errors were encountered: