enhanced error reporting in netdataErrorCallback() #268
Costa Tsaousis (ktsaou) committed
Apr 19, 2016 at 01:40 UTC
e615949fe630eb14cd68660c22016d6c1df66853
1 file changed
+17
-13
web/dashboard.js
+17
-13
@@ -11,7 +11,7 @@
11
// var netdataNoC3 = true; // do not use C3
12
// var netdataNoBootstrap = true; // do not load bootstrap
13
// var netdataDontStart = true; // do not start the thread to process the charts
14
-// var netdataErrorCallback = function(code,msg) {} // Callback function that will be invoked upon error
14
+// var netdataErrorCallback = null; // Callback function that will be invoked upon error
15
//
16
// You can also set the default netdata server, using the following.
17
// When this variable is not set, we assume the page is hosted on your
@@ -474,11 +474,12 @@
474
475
console.log("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
476
477
- if(typeof netdataErrorCallback === 'function') {
478
- netdataErrorCallback(code,msg);
479
- }
480
-
481
- if(NETDATA.errorCodes[code].alert)
477
+ var ret = true;
478
+ if(typeof netdataErrorCallback === 'function') {
479
+ ret = netdataErrorCallback('system', code, msg);
480
+ }
481
+
482
+ if(ret && NETDATA.errorCodes[code].alert)
483
alert("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
484
};
485
@@ -874,15 +875,18 @@
875
/* error() - private
876
* show an error instead of the chart
877
*/
877
- var error = function(msg) {
878
+ var error = function(msg) {
879
+ var ret = true;
880
879
- if(typeof netdataErrorCallback === 'function') {
880
- netdataErrorCallback("", msg);
881
- }
881
+ if(typeof netdataErrorCallback === 'function') {
882
+ ret = netdataErrorCallback('chart', that.id, msg);
883
+ }
884
883
- that.element.innerHTML = that.id + ': ' + msg;
884
- that.enabled = false;
885
- that.current = that.pan;
885
+ if(ret) {
886
+ that.element.innerHTML = that.id + ': ' + msg;
887
+ that.enabled = false;
888
+ that.current = that.pan;
889
+ }
890
};
891
892
// GUID - a unique identifier for the chart