Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 62145 invoked from network); 10 Jun 2008 18:20:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2008 18:20:32 -0000 Received: (qmail 38027 invoked by uid 500); 10 Jun 2008 18:20:28 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 38003 invoked by uid 500); 10 Jun 2008 18:20:28 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 37992 invoked by uid 99); 10 Jun 2008 18:20:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 11:20:27 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.69.42.181] (HELO radix.cryptio.net) (208.69.42.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 18:19:38 +0000 Received: by radix.cryptio.net (Postfix, from userid 1007) id 24C5D71C528; Tue, 10 Jun 2008 11:19:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by radix.cryptio.net (Postfix) with ESMTP id 1AE9271C527 for ; Tue, 10 Jun 2008 11:19:56 -0700 (PDT) Date: Tue, 10 Jun 2008 11:19:55 -0700 (PDT) From: Chris Hostetter To: java-user@lucene.apache.org Subject: Re: How to get the error position in QueryParser/ParseException In-Reply-To: <200805231059.37109.wzzelfzzel@abas.de> Message-ID: References: <200805231059.37109.wzzelfzzel@abas.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Checked: Checked by ClamAV on apache.org : : 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