aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cowan <agentme49@gmail.com>2015-05-14 12:03:54 -0700
committerRichard van Velzen <rvanvelzen@experty.com>2015-07-29 15:05:59 +0200
commitd6814050dd42298abb02e3fee2856174e02f01fa (patch)
tree431560d7b689f104c0b3ae52107e4f37881b7882
parent252fc65558e40e5e0a451f8fe3f2d5ae7a639457 (diff)
downloadtracifyjs-d6814050dd42298abb02e3fee2856174e02f01fa.tar.gz
tracifyjs-d6814050dd42298abb02e3fee2856174e02f01fa.zip
Give a good error message if an invalid regular expression is found.
-rw-r--r--lib/parse.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/parse.js b/lib/parse.js
index e65c4faa..70ee2e80 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -480,7 +480,13 @@ function tokenizer($TEXT, filename, html5_comments) {
regexp += ch;
}
var mods = read_name();
- return token("regexp", new RegExp(regexp, mods));
+ var r;
+ try {
+ r = new RegExp(regexp, mods);
+ } catch(e) {
+ parse_error("Invalid regular expression");
+ }
+ return token("regexp", r);
});
function read_operator(prefix) {