gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-merchant-demos] branch master updated: avoid throwing stack


From: gnunet
Subject: [taler-taler-merchant-demos] branch master updated: avoid throwing stacks in UI
Date: Wed, 12 May 2021 10:50:40 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository taler-merchant-demos.

The following commit(s) were added to refs/heads/master by this push:
     new d31b17b  avoid throwing stacks in UI
d31b17b is described below

commit d31b17b9c923af099dd103e2a2e12dafffb8dcd5
Author: MS <ms@taler.net>
AuthorDate: Wed May 12 10:50:36 2021 +0200

    avoid throwing stacks in UI
---
 talermerchantdemos/donations/donations.py |  7 +------
 talermerchantdemos/httpcommon/__init__.py | 17 ++++++-----------
 talermerchantdemos/survey/survey.py       |  9 ++-------
 3 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/talermerchantdemos/donations/donations.py 
b/talermerchantdemos/donations/donations.py
index f465ca6..01e8f12 100644
--- a/talermerchantdemos/donations/donations.py
+++ b/talermerchantdemos/donations/donations.py
@@ -134,12 +134,7 @@ def expect_parameter(name):
 #         (and execution stack!).
 @app.errorhandler(Exception)
 def internal_error(e):
-    return flask.render_template(
-        "donations-error.html.j2",
-        message=gettext("Internal error"),
-        stack=traceback.format_exc(),
-    )
-
+    return flask.render_template("donations-error.html.j2", message=str(e))
 
 ##
 # Serve the /favicon.ico requests.
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
 
 
diff --git a/talermerchantdemos/survey/survey.py 
b/talermerchantdemos/survey/survey.py
index b5ea9c8..b25d6e5 100644
--- a/talermerchantdemos/survey/survey.py
+++ b/talermerchantdemos/survey/survey.py
@@ -95,12 +95,7 @@ app.context_processor(make_utility_processor("survey"))
 #         (and execution stack!).
 @app.errorhandler(Exception)
 def internal_error(e):
-    return flask.render_template(
-        "survey-error.html.j2",
-        message=gettext("Internal error"),
-        stack=traceback.format_exc(),
-    )
-
+    return flask.render_template("survey-error.html.j2", message=str(e))
 
 ##
 # Serve the /favicon.ico requests.
@@ -184,4 +179,4 @@ def handler_backend_exception(e):
         json=e.backend_json,
         status_code=e.backend_status,
     )
-    return flask.make_response(t, 500)
\ No newline at end of file
+    return flask.make_response(t, 500)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]