-
Notifications
You must be signed in to change notification settings - Fork 30
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
Define a custom exception class instead of raising generic exceptions #40
Comments
Throwing a generic
|
Makes sense, but instead of kaitai_struct_python_runtime/kaitaistruct.py Lines 842 to 849 in d0058ac
Currently, it's only used by In general, I don't think a user needs to be able to distinguish exceptions raised during parsing from exceptions raised during serialization via the type system. After all, they start the process of parsing/serialization themselves by calling The problem with |
Currently, when a Kaitai Struct parser detects that the input data is invalid, it can raise a variety of exceptions:
ValueError
,EOFError
, genericException
, and possibly some others. This makes it very difficult for callers to specifically catch parse errors.It would be helpful to have a custom exception class (e. g.
kaitaistruct.ParseError
) that is consistently raised for all invalid input data. This would allow the calling code to catch and handle that exception specifically, without catching other unrelated errors by accident.The text was updated successfully, but these errors were encountered: