]> arthur.barton.de Git - netdata.git/commitdiff
enhanced error reporting in netdataErrorCallback() #268
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 18 Apr 2016 22:40:20 +0000 (01:40 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 18 Apr 2016 22:40:20 +0000 (01:40 +0300)
web/dashboard.js

index 39f8547bfb7a6083bc455a2c86fe035d1e26546b..5e1dd51c353e39a9f415bc8a915d20eacbd674ff 100644 (file)
@@ -11,7 +11,7 @@
 // var netdataNoC3 = true;                             // do not use C3
 // var netdataNoBootstrap = true;              // do not load bootstrap
 // var netdataDontStart = true;                        // do not start the thread to process the charts
-// var netdataErrorCallback = function(code,msg) {} // Callback function that will be invoked upon error
+// var netdataErrorCallback = null;            // Callback function that will be invoked upon error
 //
 // You can also set the default netdata server, using the following.
 // When this variable is not set, we assume the page is hosted on your
 
                console.log("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
 
-                if(typeof netdataErrorCallback === 'function') {
-                   netdataErrorCallback(code,msg);
-                }
-            
-               if(NETDATA.errorCodes[code].alert)
+               var ret = true;
+               if(typeof netdataErrorCallback === 'function') {
+                  ret = netdataErrorCallback('system', code, msg);
+               }
+
+               if(ret && NETDATA.errorCodes[code].alert)
                        alert("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
        };
 
                /* error() - private
                 * show an error instead of the chart
                 */
-               var error = function(msg) {
+               var error = function(msg) {
+                       var ret = true;
 
-                if(typeof netdataErrorCallback === 'function') {
-                   netdataErrorCallback("", msg);
-                }
+                       if(typeof netdataErrorCallback === 'function') {
+                               ret = netdataErrorCallback('chart', that.id, msg);
+                       }
 
-                       that.element.innerHTML = that.id + ': ' + msg;
-                       that.enabled = false;
-                       that.current = that.pan;
+                       if(ret) {
+                               that.element.innerHTML = that.id + ': ' + msg;
+                               that.enabled = false;
+                               that.current = that.pan;
+                       }
                };
 
                // GUID - a unique identifier for the chart