From 4d62c0810b75d2b869ad855190f2a27fe47f764c Mon Sep 17 00:00:00 2001 From: Pierre Lancien Date: Sun, 6 Oct 2013 19:46:32 +0200 Subject: [PATCH] replaced simple string errors with full Errors, in order to make debugging easier. --- lib/ace/ace.js | 2 +- lib/ace/edit_session/fold.js | 4 ++-- lib/ace/edit_session/fold_line.js | 4 ++-- lib/ace/edit_session/folding.js | 4 ++-- lib/ace/edit_session_test.js | 2 +- lib/ace/ext/textarea.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ace/ace.js b/lib/ace/ace.js index 34859be4..773f2279 100644 --- a/lib/ace/ace.js +++ b/lib/ace/ace.js @@ -75,7 +75,7 @@ exports.edit = function(el) { var _id = el; var el = document.getElementById(_id); if (!el) - throw "ace.edit can't find div #" + _id; + throw new Error("ace.edit can't find div #" + _id); } if (el.env && el.env.editor instanceof Editor) diff --git a/lib/ace/edit_session/fold.js b/lib/ace/edit_session/fold.js index 0f898021..232101bd 100644 --- a/lib/ace/edit_session/fold.js +++ b/lib/ace/edit_session/fold.js @@ -78,7 +78,7 @@ oop.inherits(Fold, RangeList); return; if (!this.range.containsRange(fold)) - throw "A fold can't intersect already existing fold" + fold.range + this.range; + throw new Error("A fold can't intersect already existing fold" + fold.range + this.range); // transform fold to local coordinates consumeRange(fold, this.start); @@ -104,7 +104,7 @@ oop.inherits(Fold, RangeList); var afterEnd = this.subFolds[j]; if (cmp == 0) - throw "A fold can't intersect already existing fold" + fold.range + this.range; + throw new Error("A fold can't intersect already existing fold" + fold.range + this.range); var consumedFolds = this.subFolds.splice(i, j - i, fold); fold.setFoldLine(this.foldLine); diff --git a/lib/ace/edit_session/fold_line.js b/lib/ace/edit_session/fold_line.js index e9f732c4..0218195e 100644 --- a/lib/ace/edit_session/fold_line.js +++ b/lib/ace/edit_session/fold_line.js @@ -71,7 +71,7 @@ function FoldLine(foldData, folds) { this.addFold = function(fold) { if (fold.sameRow) { if (fold.start.row < this.startRow || fold.endRow > this.endRow) { - throw "Can't add a fold to this FoldLine as it has no connection"; + throw new Error("Can't add a fold to this FoldLine as it has no connection"); } this.folds.push(fold); this.folds.sort(function(a, b) { @@ -93,7 +93,7 @@ function FoldLine(foldData, folds) { this.start.row = fold.start.row; this.start.column = fold.start.column; } else { - throw "Trying to add fold to FoldRow that doesn't have a matching row"; + throw new Error("Trying to add fold to FoldRow that doesn't have a matching row"); } fold.foldLine = this; } diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index 3aefea84..a9b2ddd1 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -274,7 +274,7 @@ function Folding() { // --- Some checking --- if (!(startRow < endRow || startRow == endRow && startColumn <= endColumn - 2)) - throw "The range has to be at least 2 characters width"; + throw new Error("The range has to be at least 2 characters width"); var startFold = this.getFoldAt(startRow, startColumn, 1); var endFold = this.getFoldAt(endRow, endColumn, -1); @@ -285,7 +285,7 @@ function Folding() { (startFold && !startFold.range.isStart(startRow, startColumn)) || (endFold && !endFold.range.isEnd(endRow, endColumn)) ) { - throw "A fold can't intersect already existing fold" + fold.range + startFold.range; + throw new Error("A fold can't intersect already existing fold" + fold.range + startFold.range); } // Check if there are folds in the range we create the new fold for. diff --git a/lib/ace/edit_session_test.js b/lib/ace/edit_session_test.js index 0fbaf3d3..87cc9567 100644 --- a/lib/ace/edit_session_test.js +++ b/lib/ace/edit_session_test.js @@ -937,7 +937,7 @@ module.exports = { fail = true; } if (fail != shouldFail) { - throw "Expected to get an exception"; + throw new Error("Expected to get an exception"); } } diff --git a/lib/ace/ext/textarea.js b/lib/ace/ext/textarea.js index fee9b9b2..86b299e6 100644 --- a/lib/ace/ext/textarea.js +++ b/lib/ace/ext/textarea.js @@ -74,7 +74,7 @@ function applyStyles(elm, styles) { function setupContainer(element, getValue) { if (element.type != 'textarea') { - throw "Textarea required!"; + throw new Error("Textarea required!"); } var parentNode = element.parentNode;