Pass user friendly error message to UI on invalid regular expression

This commit is contained in:
Owen Stephens 2017-11-28 16:22:17 +00:00
parent d64dee71dd
commit 21741ad09e

View File

@ -50,6 +50,7 @@ import com.google.refine.expr.Evaluable;
import com.google.refine.grel.ast.VariableExpr; import com.google.refine.grel.ast.VariableExpr;
import com.google.refine.model.Column; import com.google.refine.model.Column;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.util.PatternSyntaxExceptionParser;
public class TextSearchFacet implements Facet { public class TextSearchFacet implements Facet {
/* /*
@ -106,7 +107,8 @@ public class TextSearchFacet implements Facet {
_query, _query,
_caseSensitive ? 0 : Pattern.CASE_INSENSITIVE); _caseSensitive ? 0 : Pattern.CASE_INSENSITIVE);
} catch (java.util.regex.PatternSyntaxException e) { } catch (java.util.regex.PatternSyntaxException e) {
throw new JSONException(e); PatternSyntaxExceptionParser err = new PatternSyntaxExceptionParser(e);
throw new JSONException(err.getUserMessage());
} }
} else if (!_caseSensitive) { } else if (!_caseSensitive) {
_query = _query.toLowerCase(); _query = _query.toLowerCase();