LUCENE-1646: when throwing ParseException from QueryParser, include root cause

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@787805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-06-23 19:55:28 +00:00
parent 87de0c9688
commit 434da77559
1 changed files with 10 additions and 3 deletions

View File

@ -174,13 +174,20 @@ public class QueryParser implements QueryParserConstants {
} }
catch (ParseException tme) { catch (ParseException tme) {
// rethrow to include the original query: // rethrow to include the original query:
throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage()); // rethrow to include the original query:
ParseException e = new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());
e.initCause(tme);
throw e;
} }
catch (TokenMgrError tme) { catch (TokenMgrError tme) {
throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage()); ParseException e = new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());
e.initCause(tme);
throw e;
} }
catch (BooleanQuery.TooManyClauses tmc) { catch (BooleanQuery.TooManyClauses tmc) {
throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses"); ParseException e = new ParseException("Cannot parse '" +query+ "': too many boolean clauses");
e.initCause(tmc);
throw e;
} }
} }