From 1586375bba4637c163a10e141d4b54a46064e0a3 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 30 Jun 2014 20:33:35 -0700 Subject: [PATCH] Ian learns how to use exceptions in JavaScript. --- recentrunes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recentrunes.js b/recentrunes.js index 2e1341b..439f8c1 100644 --- a/recentrunes.js +++ b/recentrunes.js @@ -576,7 +576,8 @@ rr.ZeroOrMore_.prototype.match = function(context) { return { 'done': true }; } if (next['value']['context'].remaining() == context.remaining()) { - throw "Child of ZeroOrMore didn't consume input; grammar bug?"; + throw new Error( + "Child of ZeroOrMore didn't consume input; grammar bug?"); } return next; }.bind(this) @@ -751,7 +752,7 @@ rr.Context.prototype.remaining = function() { */ rr.Context.prototype.advance = function(numChars) { if (!numChars) { - throw 'Context.advance(0) called'; + throw new Error('Context.advance(0) called'); } var context = this.copy(); context.inputIndex += numChars;