fix(errors): standardize error handling with custom exception classes#1
Open
twenty-tools wants to merge 2 commits intomainfrom
Open
fix(errors): standardize error handling with custom exception classes#1twenty-tools wants to merge 2 commits intomainfrom
twenty-tools wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
4 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lighthouseweb3/functions/upload.py">
<violation number="1" location="src/lighthouseweb3/functions/upload.py:56">
P2: Catching `Exception` here re-wraps `LighthouseAPIError` (already raised by `Axios` methods) into a `LighthouseUploadError`, erasing the original exception type. Let `LighthouseError` subclasses propagate and only wrap unexpected errors.</violation>
</file>
<file name="src/lighthouseweb3/functions/deal_status.py">
<violation number="1" location="src/lighthouseweb3/functions/deal_status.py:13">
P2: Use `raise LighthouseAPIError(...) from error` to explicitly chain the original `HTTPError`. Without `from`, the cause is only implicitly attached, producing a less clear traceback and making it easy for callers to miss the original status code and URL context.</violation>
</file>
<file name="src/lighthouseweb3/functions/axios.py">
<violation number="1" location="src/lighthouseweb3/functions/axios.py:21">
P2: The try body only does string concatenation, which cannot raise `LighthouseAPIError` or `HTTPError`. This except clause is unreachable. Either remove the try/except entirely or catch the exceptions that dict iteration/string formatting can actually raise (e.g., `TypeError`).</violation>
<violation number="2" location="src/lighthouseweb3/functions/axios.py:30">
P1: Same resource-leak issue as `post_files`: non-`HTTPError` request failures (e.g. `ConnectionError`) skip the except block, so `file.close()` never runs. Widen the catch to `RequestException` or move cleanup to a `finally`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Author
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.
Fixes lighthouse-web3#10
Summary
Adds custom exception classes to standardize API and upload error handling, removing generic exception wrapping in the core paths touched by this issue.
Changes
src/lighthouseweb3/functions/exceptions.pywithLighthouseError,LighthouseAPIError, andLighthouseUploadError.deal_status.pyto raiseLighthouseAPIErrorinstead of generic exceptions.axios.pyto raiseLighthouseAPIErroron HTTP failures.upload.pyto raiseLighthouseUploadErrorand avoid debug print noise.Scope note
This PR is intentionally scoped to issue lighthouse-web3#10 error handling. PR lighthouse-web3#11 addresses broader concerns like type hints, docstrings, and resource management.
Validation
python -m unittest discover tests/