summaryrefslogtreecommitdiff
path: root/jarmon/jarmon.js
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-08-25 22:20:41 +0100
committerRichard Wall <richard@aziz>2010-08-25 22:20:41 +0100
commit64f965d74374f3a15342bf6e807ac50513a69f68 (patch)
tree1991e3e801cb2cfd24601f28e9bc220e011796ab /jarmon/jarmon.js
parenta741b9e561512e258fe4a589ac074c548eb37e3a (diff)
Add a test for query timerange
Diffstat (limited to 'jarmon/jarmon.js')
-rw-r--r--jarmon/jarmon.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js
index 44c4dad..6296fc5 100644
--- a/jarmon/jarmon.js
+++ b/jarmon/jarmon.js
@@ -27,6 +27,7 @@ if(typeof jarmon == 'undefined') {
var jarmon = {};
}
+
jarmon.downloadBinary = function(url) {
/**
* Download a binary file asynchronously using the jQuery.ajax function
@@ -126,6 +127,20 @@ jarmon.localTimeFormatter = function (v, axis) {
};
+jarmon.TimeRangeError = function(message) {
+ /**
+ * Raised when an invalid timerange is encountered.
+ *
+ * @class jarmon.TimeRangeError
+ * @constructor
+ * @param message {String} A description of the error reason
+ **/
+ this.name = "TimeRangeError";
+ this.message = (message || "");
+}
+jarmon.TimeRangeError.prototype = Error.prototype;
+
+
/**
* A wrapper around an instance of javascriptrrd.RRDFile which provides a
* convenient way to query the RRDFile based on time range, RRD data source (DS)
@@ -156,6 +171,14 @@ jarmon.RrdQuery.prototype.getData = function(startTime, endTime, dsId, cfName) {
* @return {Object} A Flot compatible data series
* eg label: '', data: [], unit: ''
**/
+
+ if (startTime >= endTime) {
+ throw new jarmon.TimeRangeError(
+ ['starttime must be less than endtime. ',
+ 'starttime: ', starttime,
+ 'endtime: ', endtime].join(''));
+ }
+
var startTimestamp = startTime/1000;
var lastUpdated = this.rrd.getLastUpdate();