Skip to content

Commit 11af14b

Browse files
authored
Surface too many requests exception (#3048)
# Rationale for this change Currently there's no way to catch just the HTTP code 429 ## Are these changes tested? ## Are there any user-facing changes? No
1 parent ec0a451 commit 11af14b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pyiceberg/catalog/rest/response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
RESTError,
2929
ServerError,
3030
ServiceUnavailableError,
31+
TooManyRequestsError,
3132
UnauthorizedError,
3233
)
3334
from pyiceberg.typedef import IcebergBaseModel
@@ -79,6 +80,8 @@ def _handle_non_200_response(exc: HTTPError, error_handler: dict[int, type[Excep
7980
exception = RESTError
8081
elif code == 419:
8182
exception = AuthorizationExpiredError
83+
elif code == 429:
84+
exception = TooManyRequestsError
8285
elif code == 501:
8386
exception = NotImplementedError
8487
elif code == 503:

pyiceberg/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class AuthorizationExpiredError(RESTError):
8484
"""When the credentials are expired when performing an action on the REST catalog."""
8585

8686

87+
class TooManyRequestsError(RESTError):
88+
"""Raises when too many requests error is returned by the REST catalog."""
89+
90+
8791
class OAuthError(RESTError):
8892
"""Raises when there is an error with the OAuth call."""
8993

0 commit comments

Comments
 (0)