Skip to content

Adding exceptions#18

Open
Antika7 wants to merge 2 commits into
zerodha:masterfrom
Antika7:master
Open

Adding exceptions#18
Antika7 wants to merge 2 commits into
zerodha:masterfrom
Antika7:master

Conversation

@Antika7
Copy link
Copy Markdown

@Antika7 Antika7 commented Mar 28, 2026

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 from rbiparser.exceptions, making errors easier to catch and handle programmatically.

Changes

exceptions.py

created class to include exceptions

init.py

Function Exception raised
get_sheet_urls – bad HTTP status DownloadError
get_sheet_urls – no .xlsx links found ParseError
convert_xlsx_to_csv – workbook can't be opened ParseError
convert_xlsx_to_csv – header column mismatch ParseError
convert_xlsx_to_csv – sheet conversion fails ParseError
save_etags – file write failure StorageError
get_url_headers – network error DownloadError
download – fetch failure DownloadError
download – disk write failure StorageError

Bug fixes (incidental)

Four of the original raises used the multi-argument form Exception("msg", var, ...), which stores a tuple in args[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 of RBIParserError, so existing broad except RBIParserError handlers are unaffected.

@Antika7
Copy link
Copy Markdown
Author

Antika7 commented Mar 28, 2026

@knadh @vividvilla Please review this fix for issue 15

Kindly review and merge accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suggestion: On exception raising

1 participant