remove unnecessary wrap error logic#60
Merged
bryan-unstructured merged 4 commits intomainfrom Aug 12, 2025
Merged
Conversation
There was a problem hiding this comment.
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_errorfunction from the errors module - Replaces
wrap_errorcalls with directstatus_codeattribute checking usinghasattr - Falls back to
HTTP_500_INTERNAL_SERVER_ERRORwhen exceptions don't have astatus_codeattribute
| 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.
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.
Suggested change
| else status.HTTP_500_INTERNAL_SERVER_ERROR, | |
| status_code=get_status_code_from_exception(e), |
Contributor
Author
There was a problem hiding this comment.
code duplication is minimum here
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.
wrap_error logic is no longer needed because exceptions are already categorized in unstructured-ingest. more details Unstructured-IO/unstructured-ingest#583