From 85222bfd64d2d1c7dd19b373398f5f8675ab1775 Mon Sep 17 00:00:00 2001 From: wimrijnders Date: Mon, 17 Oct 2016 17:44:22 +0200 Subject: [PATCH] throw real Error instances (#2160) --- lib/graph3d/Filter.js | 4 ++-- lib/graph3d/Graph3d.js | 8 ++++---- lib/graph3d/Slider.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/graph3d/Filter.js b/lib/graph3d/Filter.js index 2315104c..41d734a3 100644 --- a/lib/graph3d/Filter.js +++ b/lib/graph3d/Filter.js @@ -111,7 +111,7 @@ Filter.prototype.getValues = function() { */ Filter.prototype.getValue = function(index) { if (index >= this.values.length) - throw 'Error: index out of range'; + throw new Error('Index out of range'); return this.values[index]; }; @@ -164,7 +164,7 @@ Filter.prototype.setOnLoadCallback = function(callback) { */ Filter.prototype.selectValue = function(index) { if (index >= this.values.length) - throw 'Error: index out of range'; + throw new Error('Index out of range'); this.index = index; this.value = this.values[index]; diff --git a/lib/graph3d/Graph3d.js b/lib/graph3d/Graph3d.js index e13e53f7..c8814d77 100644 --- a/lib/graph3d/Graph3d.js +++ b/lib/graph3d/Graph3d.js @@ -249,7 +249,7 @@ Graph3d.prototype._setBackgroundColor = function(backgroundColor) { // use use defaults } else { - throw 'Unsupported type of backgroundColor'; + throw new Error('Unsupported type of backgroundColor'); } this.frame.style.backgroundColor = fill; @@ -333,7 +333,7 @@ Graph3d.prototype._determineColumnIndexes = function(data, style) { } } else { - throw 'Unknown style "' + this.style + '"'; + throw new Error('Unknown style "' + this.style + '"'); } }; @@ -702,7 +702,7 @@ Graph3d.prototype._resizeCanvas = function() { */ Graph3d.prototype.animationStart = function() { if (!this.frame.filter || !this.frame.filter.slider) - throw 'No animation available'; + throw new Error('No animation available'); this.frame.filter.slider.play(); }; @@ -937,7 +937,7 @@ Graph3d.prototype.setOptions = function (options) { */ Graph3d.prototype.redraw = function() { if (this.dataPoints === undefined) { - throw 'Error: graph data not initialized'; + throw new Error('Graph data not initialized'); } this._resizeCanvas(); diff --git a/lib/graph3d/Slider.js b/lib/graph3d/Slider.js index dd688e50..f6f21ecc 100644 --- a/lib/graph3d/Slider.js +++ b/lib/graph3d/Slider.js @@ -11,7 +11,7 @@ var util = require('../util'); */ function Slider(container, options) { if (container === undefined) { - throw 'Error: No container element defined'; + throw new Error('No container element defined'); } this.container = container; this.visible = (options && options.visible != undefined) ? options.visible : true; @@ -253,7 +253,7 @@ Slider.prototype.setIndex = function(index) { this.onChange(); } else { - throw 'Error: index out of range'; + throw new Error('Index out of range'); } };