Skip to content

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

Merged
merged 4 commits into from
Aug 12, 2025

Conversation

bryan-unstructured
Copy link
Contributor

@bryan-unstructured bryan-unstructured commented Aug 12, 2025

wrap_error logic is no longer needed because exceptions are already categorized in unstructured-ingest. more details Unstructured-IO/unstructured-ingest#583

Copy link

@Copilot Copilot AI left a 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 direct status_code attribute checking using hasattr
  • Falls back to HTTP_500_INTERNAL_SERVER_ERROR when exceptions don't have a status_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,
Copy link
Preview

Copilot AI Aug 12, 2025

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.

Suggested change
else status.HTTP_500_INTERNAL_SERVER_ERROR,
status_code=get_status_code_from_exception(e),

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

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

Copy link
Contributor

@yuming-long yuming-long left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bryan-unstructured bryan-unstructured merged commit 52e6815 into main Aug 12, 2025
9 checks passed
@bryan-unstructured bryan-unstructured deleted the ENG-319-optimize-error-handling branch August 12, 2025 18:40
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.

2 participants