summaryrefslogtreecommitdiff
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
parentb38ef7b67f6493dda378648e70c81daf405b2073 (diff)
Throw an error in find_var when a given var name doesn't exist
-rw-r--r--docs/examples/assets/js/jsrrdgraph.js26
-rw-r--r--docs/examples/index.html6
2 files changed, 18 insertions, 14 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.';
}
diff --git a/docs/examples/index.html b/docs/examples/index.html
index 03bf492..ddd2a50 100644
--- a/docs/examples/index.html
+++ b/docs/examples/index.html
@@ -64,19 +64,19 @@ AREA:s_min#FFFFFF
"GPRINT:s_avg:AVERAGE:%4.2lf Avg,"
"GPRINT:s_max:MAX:%4.2lf Max,"
"GPRINT:s_avg:LAST:%4.2lf Last,"
-"GPRINT:s_pct:%6.2lf 95th\n"
+"GPRINT:s_pct:AVERAGE:%6.2lf 95th\n"
"LINE1:m_avg#0000FF: 5m average"
"GPRINT:m_min:MIN:%4.2lf Min,"
"GPRINT:m_avg:AVERAGE:%4.2lf Avg,"
"GPRINT:m_max:MAX:%4.2lf Max,"
"GPRINT:m_avg:LAST:%4.2lf Last,"
-"GPRINT:m_pct:%6.2lf 95th\n"
+"GPRINT:m_pct:AVERAGE:%6.2lf 95th\n"
"LINE1:l_avg#FF0000:15m average"
"GPRINT:l_min:MIN:%4.2lf Min,"
"GPRINT:l_avg:AVERAGE:%4.2lf Avg,"
"GPRINT:l_max:MAX:%4.2lf Max,"
"GPRINT:l_avg:LAST:%4.2lf Last,"
-"GPRINT:l_pct:%6.2lf 95th\n"
+"GPRINT:l_pct:AVERAGE:%6.2lf 95th\n"
</textarea>
<div class="chartRangeControl">
<form>