Hello

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.

The reason is that ParseException has two different modes of 
instantiation distinguished by "specialConstructor". As it gets copied 
within the lucene code (specialConstructor==false) the currentToken 
variable is lost.

I guess it would be nice to add the position of the error. Any other way 
I have overlooked? I could parse the output of getMessage(), but that 
is not fine.

==================================================================
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;

public class TestParseException {

    public static void main(String[] args) {
        QueryParser parser = new QueryParser("any",
                new WhitespaceAnalyzer());
        try {
            parser.parse("b("); // yields ParseException
        }
        catch (ParseException e) {
            System.out.println("e.currentToken=" + e.currentToken);
            if (e.currentToken != null) {
                System.out.println("e.currentToken.beginColumn="
                        + e.currentToken.beginColumn);
            }
            System.out.println("message=" + e.getMessage());
        }
    }

}
==================================================================

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to