taler-merchant-demos

Python-based Frontends for the Demonstration Web site
Log | Files | Refs | Submodules | README | LICENSE

commit 2626ecc64d373dfaccfd2eb365c4744d52689360
parent add77184cba4f046ffaae4a3872c81861de9b15e
Author: ms <ms@taler.net>
Date:   Thu, 31 Mar 2022 15:40:01 +0200

error management

Diffstat:
Mtalermerchantdemos/httpcommon/__init__.py | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/talermerchantdemos/httpcommon/__init__.py b/talermerchantdemos/httpcommon/__init__.py @@ -14,7 +14,7 @@ LOGGER = logging.getLogger(__name__) class BackendException(Exception): """Exception for failed communication with the Taler merchant backend""" - def __init__(self, message, backend_status=None, backend_json=None): + def __init__(self, message, backend_status=None, backend_json={}): super().__init__(backend_json.get("hint", message)) self.backend_status = backend_status self.backend_json = backend_json @@ -41,9 +41,9 @@ def backend_post(backend_url, endpoint, json, auth_token=None): ) try: response_json = resp.json() - except ValueError: + except Exception: raise BackendException( - message=gettext("Could not parse response from backend"), + message=gettext("Could not parse the response from backend"), backend_status=resp.status_code, ) if resp.status_code != 200: @@ -81,7 +81,7 @@ def backend_get(backend_url, endpoint, params, auth_token=None): ) try: response_json = resp.json() - except ValueError: + except Exception: raise BackendException(message=gettext("Could not parse response from backend")) if resp.status_code != 200: raise BackendException(