-
Notifications
You must be signed in to change notification settings - Fork 46
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
Replace lit.error by raise LoadError #348
Conversation
Reviewer's Guide by SourceryThis pull request replaces the File-Level Changes
Tips
|
Here's the code health analysis summary for commits Analysis Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tovrstra - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 5 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 4 issues found
- 🟢 Complexity: all looks good
- 🟡 Documentation: 1 issue found
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems OK to me.
Thanks for checking Paul! |
This is another step in #191. As a sideline in fixing that issue, the IOData error handling is improved in general, not just for errors and warnings when data is converted before writing it out.
The old code used a wrapper function
lit.error
to raise an exception when a file cannot be read for some reason. This function adds some info (filename and line number) to the error message. This was a bad idea for several reasons:raise LoadError(...) from exc
calls.raise LoadError(...
.lit.error(...)
interrupts the control flow, leaving poor code undetected. (We had some of that in the gro and cp2klog formats, fixed in this PR.)The logic that was in
LineIterator.error
has now been implemented in theLoadError
exception, and has been generalized to work well for all use cases.I will YOLO-merge this on Friday, June 28, unless reviewed earlier.
Summary by Sourcery
This pull request refactors error handling by replacing the custom
lit.error
function with directraise LoadError
calls. This change improves code readability, allows for better exception chaining, and enhances error reporting by including filename and line number information in theLoadError
exception. Additionally, test cases have been updated to reflect these changes.lit.error
function with directraise LoadError
calls to improve readability and allowraise ... from
syntax.LoadError
exception to include filename and line number information, enhancing error reporting across various file formats.LoadError
exceptions instead oflit.error
messages.