Skip to content

Commit 54c6448

Browse files
committed
Handle 400, 422 and 504 HTTPExceptions
1 parent db59eed commit 54c6448

File tree

1 file changed

+11
-2
lines changed
  • unstructured_platform_plugins/etl_uvicorn

1 file changed

+11
-2
lines changed

unstructured_platform_plugins/etl_uvicorn/errors.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,24 @@ class ProviderError(BaseError):
3636
status_code: int = 500
3737

3838

39+
class GatewayTimeoutError(BaseError):
40+
status_code: int = 504
41+
42+
3943
class CatchAllError(BaseError):
4044
status_code: int = 512
4145

4246

4347
def wrap_error(e: Exception) -> HTTPException:
4448
if isinstance(e, ingest_errors.UserAuthError):
4549
return UserAuthError(e)
46-
elif isinstance(e, ingest_errors.UnprocessableEntityError):
47-
return UnprocessableEntityError(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)
4857
elif isinstance(e, ingest_errors.RateLimitError):
4958
return RateLimitError(e)
5059
elif isinstance(e, ingest_errors.QuotaError):

0 commit comments

Comments
 (0)