summaryrefslogtreecommitdiff
path: root/talermerchantdemos/httpcommon/__init__.py
diff options
context:
space:
mode:
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