Skip to content

Commit d2d4373

Browse files
authored
Handle 422 errors (#53)
1 parent 6bb5f16 commit d2d4373

File tree

2 files changed

+16
-1
lines changed

2 files changed

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

unstructured_platform_plugins/etl_uvicorn/errors.py

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

2222

23+
class UnprocessableEntityError(UserError):
24+
status_code: int = 422
25+
26+
2327
class RateLimitError(UserError):
2428
status_code: int = 429
2529

@@ -32,13 +36,24 @@ class ProviderError(BaseError):
3236
status_code: int = 500
3337

3438

39+
class GatewayTimeoutError(BaseError):
40+
status_code: int = 504
41+
42+
3543
class CatchAllError(BaseError):
3644
status_code: int = 512
3745

3846

3947
def wrap_error(e: Exception) -> HTTPException:
4048
if isinstance(e, ingest_errors.UserAuthError):
4149
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)
4257
elif isinstance(e, ingest_errors.RateLimitError):
4358
return RateLimitError(e)
4459
elif isinstance(e, ingest_errors.QuotaError):

0 commit comments

Comments
 (0)