pattern matching errors are reported as coding errors

This commit is contained in:
gnembon committed 2020-09-28 15:54:56 -03:00
1 parent c4c268b079
commit 9b35c19bea
1 file changed
+10 -1
+10 -1
View File
@@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public abstract class Value implements Comparable<Value>, Cloneable public abstract class Value implements Comparable<Value>, Cloneable
{ {
@@ -145,7 +146,15 @@ public abstract class Value implements Comparable<Value>, Cloneable
public Value in(Value value1) public Value in(Value value1)
{ {
final Pattern p = Pattern.compile(value1.getString()); final Pattern p;
try
{
p = Pattern.compile(value1.getString());
}
catch (PatternSyntaxException pse)
{
throw new InternalExpressionException("Incorrect matching pattern: "+pse.getMessage());
}
final Matcher m = p.matcher(this.getString()); final Matcher m = p.matcher(this.getString());
if (!m.find()) return Value.NULL; if (!m.find()) return Value.NULL;
int gc = m.groupCount(); int gc = m.groupCount();