summaryrefslogtreecommitdiff
path: root/talermerchantdemos/httpcommon/__init__.py
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-05-12 10:50:36 +0200
committerMS <ms@taler.net>2021-05-12 10:50:36 +0200
commitd31b17b9c923af099dd103e2a2e12dafffb8dcd5 (patch)
treebdb1b34e595374ee6d8044b3d9dcfb338157640c /talermerchantdemos/httpcommon/__init__.py
parent7541de2109fc1cc5189cbb24bfc26b0cc83bd7c0 (diff)
downloadtaler-merchant-demos-d31b17b9c923af099dd103e2a2e12dafffb8dcd5.tar.gz
taler-merchant-demos-d31b17b9c923af099dd103e2a2e12dafffb8dcd5.tar.bz2
taler-merchant-demos-d31b17b9c923af099dd103e2a2e12dafffb8dcd5.zip
avoid throwing stacks in UI
Diffstat (limited to 'talermerchantdemos/httpcommon/__init__.py')
-rw-r--r--talermerchantdemos/httpcommon/__init__.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/talermerchantdemos/httpcommon/__init__.py b/talermerchantdemos/httpcommon/__init__.py
index 949621b..0d69407 100644
--- a/talermerchantdemos/httpcommon/__init__.py
+++ b/talermerchantdemos/httpcommon/__init__.py
@@ -15,18 +15,10 @@ class BackendException(Exception):
"""Exception for failed communication with the Taler merchant backend"""
def __init__(self, message, backend_status=None, backend_json=None):
- super().__init__(message)
+ super().__init__(backend_json.get("hint", message))
self.backend_status = backend_status
self.backend_json = backend_json
-def exception_handler(func):
- def inner(*args, **kwargs):
- try:
- return func(*args, **kwargs)
- except BackendException as err:
- LOGGER.error(err.backend_json)
- return inner
-
##
# POST a request to the backend, and return a error
# response if any error occurs.
@@ -35,7 +27,6 @@ def exception_handler(func):
# this request.
# @param json the POST's body.
# @return the backend response (JSON format).
-@exception_handler
def backend_post(backend_url, endpoint, json, auth_token=None):
headers = dict()
if auth_token:
@@ -61,7 +52,11 @@ def backend_post(backend_url, endpoint, json, auth_token=None):
backend_status=resp.status_code,
backend_json=response_json,
)
- print("Backend responds to {}: {}".format(final_url, str(response_json)))
+ print("Backend responds to {}: {}/{}".format(
+ final_url,
+ str(response_json),
+ resp.status_code
+ ))
return response_json