-
Notifications
You must be signed in to change notification settings - Fork 2
remove unnecessary wrap error logic #60
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
Conversation
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.
Pull Request Overview
This PR removes unnecessary error wrapping logic by simplifying exception handling in the ETL uvicorn API generator. The changes eliminate the dependency on a wrap_error
utility function and replace it with direct attribute checking.
- Removes import of
wrap_error
function from the errors module - Replaces
wrap_error
calls with directstatus_code
attribute checking usinghasattr
- Falls back to
HTTP_500_INTERNAL_SERVER_ERROR
when exceptions don't have astatus_code
attribute
status_code=http_error.status_code, | ||
status_code=e.status_code | ||
if hasattr(e, "status_code") | ||
else status.HTTP_500_INTERNAL_SERVER_ERROR, |
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.
The inline conditional logic for status_code extraction is duplicated in two places (lines 194-196 and 233-235). Consider extracting this logic into a helper function to reduce code duplication and improve maintainability.
else status.HTTP_500_INTERNAL_SERVER_ERROR, | |
status_code=get_status_code_from_exception(e), |
Copilot uses AI. Check for mistakes.
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.
code duplication is minimum here
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.
LGTM
wrap_error logic is no longer needed because exceptions are already categorized in unstructured-ingest. more details Unstructured-IO/unstructured-ingest#583