gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-backoffice] branch master updated: Aggregate commit.


From: gnunet
Subject: [GNUnet-SVN] [taler-backoffice] branch master updated: Aggregate commit.
Date: Thu, 07 Jun 2018 21:06:28 +0200

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

marcello pushed a commit to branch master
in repository backoffice.

The following commit(s) were added to refs/heads/master by this push:
     new 034e518  Aggregate commit.
034e518 is described below

commit 034e518f06163072ee69dcab8a6f0b776cdd161a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Jun 7 21:04:57 2018 +0200

    Aggregate commit.
    
    Fix the way alternative config files are read from
    command line, and add a big "switch" where error codes
    from HTTP services are read and rendered as nice-ish
    messages.
---
 js/backoffice.js                         | 73 +++++++++++++++++++++++++++++---
 taler-merchant-backoffice.in             |  3 +-
 talerbackoffice/backoffice/backoffice.py |  2 +
 3 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/js/backoffice.js b/js/backoffice.js
index 187ebf5..4f11d54 100644
--- a/js/backoffice.js
+++ b/js/backoffice.js
@@ -60,6 +60,65 @@ var LAST = 0;
 var SCROLL = true;
 
 /**
+ * Maps error codes from 
https://git.taler.net/exchange.git/tree/src/include/taler_error_codes.h
+ * to friendlier messages.
+ */
+function error_map(code){
+  switch (code){
+
+  /* /history errors.  */
+  case "2200":
+    return "The timestamp used to query the history overflowed.";
+  case "2201":
+    return "Merchant had serious problems in its history database";
+  case "2202":
+    return "The instance used to query the history is unknown";
+
+  /* /track/order errors.  */
+  case "2307":
+    /* Such errors should provide full proof to the user.  */
+    return "One of the coin was untraceable";
+  case "2308":
+  case "2408":
+    return "Conflicting reports from the Exchange";
+  case "2301":
+    return "Instance is unknown to track this order";
+  case "2303":
+  case "2304":
+  case "2305":
+  case "1801":
+    return "Merchant database failed, code:" + code;
+  case "2306":
+    return "One of the coin failed at getting its WTID";
+
+  /* /track/transfer errors.  */
+  case "2410":
+    return "Exchange charged a higher wire fee than what " +
+           " it was originally advertised.";
+  case "2405":
+    return "Error from the exchange, no proof received!";
+  case "2404":
+  case "2402":
+    return "Database failure, could not store results: " + code;
+  case "2406":
+    return "Database failure, could not retrieve previous results";
+  case "2407":
+    return "Database failure, internal logic error";
+  case "2409":
+    return "Merchant could not pack the JSON response";
+  case "2403":
+    return "Merchant failed to request /track/transfer to \
+            the exchange";
+  case "2400":
+    return "Exchange timed out..";
+
+  default:
+    return "Error code not given.";
+  } 
+
+}
+
+/**
  * Convert Taler-compliant amount to human-friendly string.
  * The amount may be both a string or object type.
  */
@@ -212,25 +271,25 @@ var show_error = show_warning = function(response_text){
   toggle_loader();
   close_popup();
 
-  var msg = response_text;
+  var msg;
+  var hint = "";
   try{
     var parse = JSON.parse(response_text);
     console.log("Response was at least JSON");
-    if (parse['error'])
-      msg = parse['error'];
+    /* handles undefined codes too.  */
+    msg = error_map(parse['code']);
 
-    /* Give precedence to 'hint' as it is usually
-     * human-friendlier */
     if (parse['hint'])
-      msg = parse['hint'];
+      hint = parse['hint'];
 
   } catch (e) {
+    msg = response_text;
     console.log("Must keep raw response");
   }
   
   /* Get hold of the info bar.  */
   var info_bar = document.getElementById("information-bar");
-  info_bar.innerHTML = `<p>${msg}</p>`; 
+  info_bar.innerHTML = `<p>${msg} ${hint}</p>`; 
   info_bar.style.visibility = "visible"; 
 }
 
diff --git a/taler-merchant-backoffice.in b/taler-merchant-backoffice.in
index 0ea5097..eed11f3 100644
--- a/taler-merchant-backoffice.in
+++ b/taler-merchant-backoffice.in
@@ -19,12 +19,12 @@ site.addsitedir("%s/lib/python%d.%d/site-packages" % (
     sys.version_info.minor))
 
 LOGGER = logging.getLogger(__name__)
-TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
 
 # No perfect match to our logging format, but good enough ...
 UWSGI_LOGFMT = "%(ltime) %(proto) %(method) %(uri) %(proto) => %(status)"
 
 def handle_serve_http(args):
+    TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
     port = args.port
     if port is None:
         port = TC["backoffice-%s" % 
args.frontend]["http_port"].value_int(required=True)
@@ -39,6 +39,7 @@ def handle_serve_http(args):
               "--env", "BACKOFFICE_INSTANCES=%s" % TC["backoffice-%s" % 
args.frontend]["instances"].value_string(required=True))
               
 def handle_serve_uwsgi(args):
+    TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
     serve_uwsgi = TC["backoffice-%s" % 
args.frontend]["uwsgi_serve"].value_string(required=True).lower()
     params = ["uwsgi", "uwsgi",
               "--master",
diff --git a/talerbackoffice/backoffice/backoffice.py 
b/talerbackoffice/backoffice/backoffice.py
index 2ce66e6..65d76ce 100644
--- a/talerbackoffice/backoffice/backoffice.py
+++ b/talerbackoffice/backoffice/backoffice.py
@@ -45,6 +45,8 @@ INSTANCES = os.environ.get("BACKOFFICE_INSTANCES")
 CURRENCY = TC["taler"]["currency"].value_string(required=True)
 app.config.from_object(__name__)
 
+print("My backend is: " + BACKEND_URL)
+
 
 @app.context_processor
 def utility_processor():

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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