Adding exceptions#18
Open
Antika7 wants to merge 2 commits into
Open
Conversation
Author
|
@knadh @vividvilla Please review this fix for issue 15 Kindly review and merge accordingly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Resolved : Link
Description -
Replace generic exceptions with typed custom exceptions
Summary
Replaces all 9 bare
raise Exception(...)calls in init.py with typed exceptions fromrbiparser.exceptions, making errors easier to catch and handle programmatically.Changes
exceptions.py
created class to include exceptions
init.py
get_sheet_urls– bad HTTP statusDownloadErrorget_sheet_urls– no.xlsxlinks foundParseErrorconvert_xlsx_to_csv– workbook can't be openedParseErrorconvert_xlsx_to_csv– header column mismatchParseErrorconvert_xlsx_to_csv– sheet conversion failsParseErrorsave_etags– file write failureStorageErrorget_url_headers– network errorDownloadErrordownload– fetch failureDownloadErrordownload– disk write failureStorageErrorBug fixes (incidental)
Four of the original raises used the multi-argument form
Exception("msg", var, ...), which stores a tuple inargs[0]rather than a human-readable string. All are now f-strings.Why
Callers can now distinguish between a network failure (
DownloadError), a malformed file (ParseError), and an I/O problem (StorageError) without parsing exception message strings. All three are subclasses ofRBIParserError, so existing broadexcept RBIParserErrorhandlers are unaffected.