commit 3f4952f15ede6fe3529f093ec4c188c0455f1d6d
parent 9b04aae3a58f0512277647c59ff99e34cb6a8b30
Author: MS <ms@taler.net>
Date: Tue, 11 May 2021 09:12:54 +0200
debug
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/talermerchantdemos/httpcommon/__init__.py b/talermerchantdemos/httpcommon/__init__.py
@@ -7,7 +7,9 @@ import time
from flask_babel import gettext
import os
import re
+import logging
+LOGGER = logging.getLogger(__name__)
class BackendException(Exception):
"""Exception for failed communication with the Taler merchant backend"""
@@ -17,6 +19,12 @@ class BackendException(Exception):
self.backend_status = backend_status
self.backend_json = backend_json
+def exception_handler(func):
+ def inner(*args, **kwargs):
+ try:
+ func(*args, **kwargs)
+ except BackendException as err:
+ LOGGER.error(err.backend_json)
##
# POST a request to the backend, and return a error
@@ -26,6 +34,7 @@ class BackendException(Exception):
# 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 is not None: