summaryrefslogtreecommitdiff
path: root/docs/examples/assets/js/jsrrdgraph.js
diff options
context:
space:
mode:
authorRichard Wall <richard@largo>2011-08-14 09:22:27 +0100
committerRichard Wall <richard@largo>2011-08-14 09:22:27 +0100
commitf476a55b0513e0e490edea38b58df42770aee835 (patch)
tree15415cc270f39a1c11f88e7c2849f39d7ed1b306 /docs/examples/assets/js/jsrrdgraph.js
parentb38ef7b67f6493dda378648e70c81daf405b2073 (diff)
Throw an error in find_var when a given var name doesn't exist
Diffstat (limited to 'docs/examples/assets/js/jsrrdgraph.js')
-rw-r--r--docs/examples/assets/js/jsrrdgraph.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/docs/examples/assets/js/jsrrdgraph.js b/docs/examples/assets/js/jsrrdgraph.js
index 7dfdcad..d296ec6 100644
--- a/docs/examples/assets/js/jsrrdgraph.js
+++ b/docs/examples/assets/js/jsrrdgraph.js
@@ -4193,14 +4193,14 @@ RRDGraph.prototype = {
find_var: function(key)
{
for (var ii = 0, gdes_c = this.gdes.length; ii < gdes_c; ii++) {
- if ((this.gdes[ii].gf === RRDGraphDesc.GF.DEF ||
- this.gdes[ii].gf === RRDGraphDesc.GF.VDEF ||
- this.gdes[ii].gf === RRDGraphDesc.GF.CDEF)
- && this.gdes[ii].vname === key) {
- return ii;
+ if ((this.gdes[ii].gf === RRDGraphDesc.GF.DEF
+ || this.gdes[ii].gf === RRDGraphDesc.GF.VDEF
+ || this.gdes[ii].gf === RRDGraphDesc.GF.CDEF)
+ && this.gdes[ii].vname === key) {
+ return ii;
+ }
}
- }
- return -1;
+ throw new Error('Key not found ' + key);
},
// DEF:<vname>=<rrdfile>:<ds-name>:<CF>[:step=<step>][:start=<time>][:end=<time>][:reduce=<CF>]
parse_def: function (line)
@@ -4235,7 +4235,7 @@ RRDGraph.prototype = {
gdp.gf = RRDGraphDesc.GF.DEF;
gdp.vname = vname;
- gdp.vidx = this.find_var(vname);
+// gdp.vidx = this.find_var(vname);
gdp.rrd = rrdfile;
gdp.ds_nam = name;
gdp.cf = this.cf_conv(cf);
@@ -4292,9 +4292,13 @@ RRDGraph.prototype = {
var index = rpn.indexOf(',');
var name = rpn.substring(0,index);
- gdp.vidx = this.find_var(name); // FIXME checks
- if (gdp.vidx === -1
- || this.gdes[gdp.vidx].gf != RRDGraphDesc.GF.DEF
+ var vidx = this.find_var(name);
+ if (vidx === -1) {
+ throw 'variable "'+name+'" does not exist in VDEF.';
+ } else {
+ gdp.vidx = vidx;
+ }
+ if (this.gdes[gdp.vidx].gf != RRDGraphDesc.GF.DEF
&& this.gdes[gdp.vidx].gf != RRDGraphDesc.GF.CDEF) {
throw 'variable "'+name+'" not DEF nor CDEF in VDEF.';
}