diff options
author | Igor Sfiligoi <isfiligoi@ucsd.edu> | 2013-03-23 16:12:34 +0000 |
---|---|---|
committer | Igor Sfiligoi <isfiligoi@ucsd.edu> | 2013-03-23 16:12:34 +0000 |
commit | 82592941fbb012a0581e63f3c22ceb5ae38a1026 (patch) | |
tree | cae3048261aefa669e0e4e198477838b41701f99 /src | |
parent | ccde18044f9a13d91d367550d72b61a03e32129a (diff) |
Better support for error in Chrome
Diffstat (limited to 'src')
-rw-r--r-- | src/examples/rrdContent.html | 4 | ||||
-rw-r--r-- | src/examples/rrdHeaderInfo.html | 4 | ||||
-rw-r--r-- | src/examples/rrdJFlot.html | 5 | ||||
-rw-r--r-- | src/examples/rrdJFlotDefaults.html | 4 | ||||
-rw-r--r-- | src/examples/rrdJFlotFilter.html | 4 | ||||
-rw-r--r-- | src/examples/rrdJFlotFilterRRA.html | 4 | ||||
-rw-r--r-- | src/examples/rrdJFlotSimple.html | 4 | ||||
-rw-r--r-- | src/examples/rrdJFlotTwo.html | 8 | ||||
-rw-r--r-- | src/examples/rrdMatrixFlot.html | 4 | ||||
-rw-r--r-- | src/lib/rrdFile.js | 2 |
10 files changed, 43 insertions, 0 deletions
diff --git a/src/examples/rrdContent.html b/src/examples/rrdContent.html index 9b87412..21d7082 100644 --- a/src/examples/rrdContent.html +++ b/src/examples/rrdContent.html @@ -161,6 +161,10 @@ // and performs the update of the Web page function update_fname_handler(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdHeaderInfo.html b/src/examples/rrdHeaderInfo.html index 3a772d7..c0feddb 100644 --- a/src/examples/rrdHeaderInfo.html +++ b/src/examples/rrdHeaderInfo.html @@ -102,6 +102,10 @@ // and performs the update of the Web page function update_info_handler(bf) { var rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdJFlot.html b/src/examples/rrdJFlot.html index 9c24f59..b5fb4a5 100644 --- a/src/examples/rrdJFlot.html +++ b/src/examples/rrdJFlot.html @@ -87,10 +87,15 @@ // and performs the update of the Web page function update_fname_handler(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { alert("File "+fname+" is not a valid RRD archive!\n"+err); + return 1; } if (i_rrd_data!=undefined) { rrd_data=i_rrd_data; diff --git a/src/examples/rrdJFlotDefaults.html b/src/examples/rrdJFlotDefaults.html index d25961e..35f1ee0 100644 --- a/src/examples/rrdJFlotDefaults.html +++ b/src/examples/rrdJFlotDefaults.html @@ -95,6 +95,10 @@ // and performs the update of the Web page function update_fname_handler(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdJFlotFilter.html b/src/examples/rrdJFlotFilter.html index c588e90..1fee276 100644 --- a/src/examples/rrdJFlotFilter.html +++ b/src/examples/rrdJFlotFilter.html @@ -127,6 +127,10 @@ // and performs the update of the Web page function update_fname_handler(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdJFlotFilterRRA.html b/src/examples/rrdJFlotFilterRRA.html index 7306e37..8f001d4 100644 --- a/src/examples/rrdJFlotFilterRRA.html +++ b/src/examples/rrdJFlotFilterRRA.html @@ -121,6 +121,10 @@ // and performs the update of the Web page function update_fname_handler(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdJFlotSimple.html b/src/examples/rrdJFlotSimple.html index 4240f70..81645c4 100644 --- a/src/examples/rrdJFlotSimple.html +++ b/src/examples/rrdJFlotSimple.html @@ -108,6 +108,10 @@ // and performs the update of the Web page function update_fname_handler(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdJFlotTwo.html b/src/examples/rrdJFlotTwo.html index 2aed031..4d1c79c 100644 --- a/src/examples/rrdJFlotTwo.html +++ b/src/examples/rrdJFlotTwo.html @@ -95,6 +95,10 @@ // and performs the update of the Web page function update_fname_handler1(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname1+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { @@ -108,6 +112,10 @@ function update_fname_handler2(bf) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File "+fname2+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/examples/rrdMatrixFlot.html b/src/examples/rrdMatrixFlot.html index 0f61b07..66b3b17 100644 --- a/src/examples/rrdMatrixFlot.html +++ b/src/examples/rrdMatrixFlot.html @@ -81,6 +81,10 @@ // and performs the update of the Web page function update_fname_handler(bf,idx) { var i_rrd_data=undefined; + if (bf.getLength()<1) { + alert("File at idx "+idx+" is empty (possibly loading failed)!"); + return 1; + } try { var i_rrd_data=new RRDFile(bf); } catch(err) { diff --git a/src/lib/rrdFile.js b/src/lib/rrdFile.js index 0f7c80d..81f7731 100644 --- a/src/lib/rrdFile.js +++ b/src/lib/rrdFile.js @@ -204,6 +204,8 @@ function RRDHeader(rrd_data) { // Internal, used for initialization
RRDHeader.prototype.validate_rrd = function() {
+ if (this.rrd_data.getLength()<1) throw new InvalidRRD("Empty file.");
+ if (this.rrd_data.getLength()<16) throw new InvalidRRD("File too short.");
if (this.rrd_data.getCStringAt(0,4)!=="RRD") throw new InvalidRRD("Wrong magic id.");
this.rrd_version=this.rrd_data.getCStringAt(4,5);
|