Better error message for bad regular expressions in GEL.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@388 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-06 06:18:07 +00:00
parent f402db10af
commit 93d6f9fc54

View File

@ -140,8 +140,13 @@ public class Parser {
} else if (_token.type == TokenType.Regex) {
RegexToken t = (RegexToken) _token;
eval = new LiteralExpr(Pattern.compile(_token.text, t.caseInsensitive ? Pattern.CASE_INSENSITIVE : 0));
next(false);
try {
Pattern pattern = Pattern.compile(_token.text, t.caseInsensitive ? Pattern.CASE_INSENSITIVE : 0);
eval = new LiteralExpr(pattern);
next(false);
} catch (Exception e) {
throw makeException("Bad regular expression (" + e.getMessage() + ")");
}
} else if (_token.type == TokenType.Number) {
eval = new LiteralExpr(((NumberToken)_token).value);
next(false);