From 33ace40608a55bd36b24370e4e1c7a25af7f9525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Praszmo?= Date: Thu, 25 Aug 2022 16:07:30 +0200 Subject: [PATCH] Handle entity-too-large HTTP errors (#81) --- mwdblib/__version__.py | 2 +- mwdblib/exc.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mwdblib/__version__.py b/mwdblib/__version__.py index aef46ac..111dc91 100644 --- a/mwdblib/__version__.py +++ b/mwdblib/__version__.py @@ -1 +1 @@ -__version__ = "4.2.1" +__version__ = "4.3.0" diff --git a/mwdblib/exc.py b/mwdblib/exc.py index 2601008..bd0fbcd 100644 --- a/mwdblib/exc.py +++ b/mwdblib/exc.py @@ -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 @@ -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)