Skip to content

Commit 61a29e7

Browse files
authored
chore [Nex-57]: remove calling wrap_error for HTTPException (#55)
we should not add each case for different HTTP status code -> should just raise one when we see one `wrap_error` should only be called for `Exception`
1 parent d2d4373 commit 61a29e7

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.33" # pragma: no cover
1+
__version__ = "0.0.34" # pragma: no cover

unstructured_platform_plugins/etl_uvicorn/api_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ async def _stream_response():
216216
usage=usage,
217217
message_channels=message_channels,
218218
filedata_meta=filedata_meta_model.model_validate(filedata_meta.model_dump()),
219-
status_code=wrap_error(exc).status_code,
220-
status_code_text=f"[{exc.__class__.__name__}] {exc}",
219+
status_code=exc.status_code,
220+
status_code_text=exc.detail,
221221
file_data=request_dict.get("file_data", None),
222222
)
223223
except UnrecoverableException as ex:

unstructured_platform_plugins/etl_uvicorn/errors.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class UserAuthError(UserError):
2020
status_code: int = 403
2121

2222

23-
class UnprocessableEntityError(UserError):
24-
status_code: int = 422
25-
26-
2723
class RateLimitError(UserError):
2824
status_code: int = 429
2925

@@ -36,24 +32,18 @@ class ProviderError(BaseError):
3632
status_code: int = 500
3733

3834

39-
class GatewayTimeoutError(BaseError):
40-
status_code: int = 504
41-
42-
4335
class CatchAllError(BaseError):
4436
status_code: int = 512
4537

4638

4739
def wrap_error(e: Exception) -> HTTPException:
48-
if isinstance(e, ingest_errors.UserAuthError):
40+
"""
41+
Wraps an exception in a HTTPException.
42+
"""
43+
if isinstance(e, HTTPException):
44+
return e
45+
elif isinstance(e, ingest_errors.UserAuthError):
4946
return UserAuthError(e)
50-
elif isinstance(e, HTTPException):
51-
if e.status_code == 400:
52-
return UserError(e)
53-
if e.status_code == 422:
54-
return UnprocessableEntityError(e)
55-
if e.status_code == 504:
56-
return GatewayTimeoutError(e)
5747
elif isinstance(e, ingest_errors.RateLimitError):
5848
return RateLimitError(e)
5949
elif isinstance(e, ingest_errors.QuotaError):

0 commit comments

Comments
 (0)