commit d31b17b9c923af099dd103e2a2e12dafffb8dcd5
parent 7541de2109fc1cc5189cbb24bfc26b0cc83bd7c0
Author: MS <ms@taler.net>
Date: Wed, 12 May 2021 10:50:36 +0200
avoid throwing stacks in UI
Diffstat:
3 files changed, 9 insertions(+), 25 deletions(-)
diff --git 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
@@ -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
@@ -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)