Skip to content

Commit

Permalink
Handle entity-too-large HTTP errors (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
nazywam authored Aug 25, 2022
1 parent 7177597 commit 33ace40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mwdblib/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.2.1"
__version__ = "4.3.0"
12 changes: 12 additions & 0 deletions mwdblib/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ class VersionMismatchError(MWDBError):
pass


class ObjectTooLargeError(MWDBError):
"""
Server signaled that the uploaded object is too large.
.. versionadded:: 4.3.0
"""

pass


def get_http_error_message(http_error: requests.exceptions.HTTPError) -> str:
import json

Expand Down Expand Up @@ -230,6 +240,8 @@ def map_http_error(http_error: requests.exceptions.HTTPError) -> MWDBError:
requests.codes.gateway_timeout,
]:
return GatewayError(http_error=http_error)
elif http_error.response.status_code == requests.codes.request_entity_too_large:
return ObjectTooLargeError(http_error=http_error)
else:
# Other codes are classified as internal error
return InternalError(http_error=http_error)

0 comments on commit 33ace40

Please sign in to comment.