Throw descriptive error for Invalid RegExp

Throws up descriptive error when parsing an invalid regular expression 
"test".match(/test/i || /test2/i);
This commit is contained in:
Rob Colburn 2014-06-24 12:53:07 -07:00
parent e3342a3cf6
commit 11aad46078

View File

@ -1153,7 +1153,12 @@ function OutputStream(options) {
}; };
DEFPRINT(AST_RegExp, function(self, output){ DEFPRINT(AST_RegExp, function(self, output){
var str = self.getValue().toString(); var str = self.getValue()
try {
str = str.toString();
} catch (e) {
throw new Error('Cannot evaluate RegExp [' + self.start.file + ':' + self.start.line + ',' + self.start.col + ']');
}
if (output.option("ascii_only")) { if (output.option("ascii_only")) {
str = output.to_ascii(str); str = output.to_ascii(str);
} else if (output.option("unescape_regexps")) { } else if (output.option("unescape_regexps")) {