Add error callback to dashboard.js
Paul Legato committed
Apr 18, 2016 at 13:44 UTC
cdf637be4838f085d990d0bc60e47b2b2e2744e0
1 file changed
+11
-1
web/dashboard.js
+11
-1
@@ -11,6 +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
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
@@ -473,6 +474,10 @@
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)
482
alert("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
483
};
@@ -867,7 +872,12 @@
872
/* error() - private
873
* show an error instead of the chart
874
*/
870
- var error = function(msg) {
875
+ var error = function(msg) {
876
+
877
+ if(typeof netdataErrorCallback === 'function') {
878
+ netdataErrorCallback("", msg);
879
+ }
880
+
881
that.element.innerHTML = that.id + ': ' + msg;
882
that.enabled = false;
883
that.current = that.pan;