From 3f4952f15ede6fe3529f093ec4c188c0455f1d6d Mon Sep 17 00:00:00 2001 From: MS Date: Tue, 11 May 2021 09:12:54 +0200 Subject: debug --- talermerchantdemos/httpcommon/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'talermerchantdemos/httpcommon/__init__.py') diff --git a/talermerchantdemos/httpcommon/__init__.py b/talermerchantdemos/httpcommon/__init__.py index 894cd7a..8546ff0 100644 --- 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: -- cgit v1.2.3