Apache Lucene open-source search software
add the original query to the parse exception message for easier debugging
Daniel Naber53888844c0fe
diff --git a/src/java/org/apache/lucene/queryParser/QueryParser.java b/src/java/org/apache/lucene/queryParser/QueryParser.javaindex bc78c270a3d..bf02c0d34a5 100644--- a/src/java/org/apache/lucene/queryParser/QueryParser.java+++ b/src/java/org/apache/lucene/queryParser/QueryParser.java@@ -121,11 +121,15 @@ public class QueryParser implements QueryParserConstants {try {return Query(field);}+ catch (ParseException tme) {+ // rethrow to include the original query:+ throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());+ }catch (TokenMgrError tme) {- throw new ParseException(tme.getMessage());+ throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());}catch (BooleanQuery.TooManyClauses tmc) {- throw new ParseException("Too many boolean clauses");+ throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses");}}diff --git a/src/java/org/apache/lucene/queryParser/QueryParser.jj b/src/java/org/apache/lucene/queryParser/QueryParser.jjindex 79402c1acb5..b293c63284c 100644--- a/src/java/org/apache/lucene/queryParser/QueryParser.jj+++ b/src/java/org/apache/lucene/queryParser/QueryParser.jj@@ -144,11 +144,15 @@ public class QueryParser {try {return Query(field);}+ catch (ParseException tme) {+ // rethrow to include the original query:+ throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());+ }catch (TokenMgrError tme) {- throw new ParseException(tme.getMessage());+ throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());}catch (BooleanQuery.TooManyClauses tmc) {- throw new ParseException("Too many boolean clauses");+ throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses");}}