lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: How to get the error position in QueryParser/ParseException
Date Tue, 10 Jun 2008 18:19:55 GMT
: 
: When using "new QueryParser(...).parse(...)" I'd like to get the 
: position where the error was detected (to show it to the user).
: See (and run) the code below.
: 
: This is not possible via "e.currentToken" (that's null). Nevertheless 
: this position will be printed within the getMessage() method but is not 
: accessible directly.

In general, QueryParser isn't a very good parser -- especally when it 
comes to error conditions.  in a lot of cases, Queryparser generates a 
ParseException because it can see that the input is "bad", but the method 
generating the exception doesn't actaully know where in the string 
the"bad" input came from -- it's already dealing with trees of Query 
objects.

if you're getting exceptions where the position info is in the getMessage, 
that means the ParseException you're getting is fro ma code path where it 
did know the position, probably from a nested exception, but it's wrapping
it very naively and loosing that piece of "structured" error info.

We'd need a patch for QueryParser to fix this ... it would probably be 
fairly straight forward, but like i said: itwould only help you in some of 
the cases, there are plenty of other places in the code where 
ParseExceptions are thrown without any idea what the parse position is.



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message