lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Why does BooleanQuery$TooManyClauses extend RuntimeException?
Date Wed, 26 Nov 2003 11:08:33 GMT
On Tuesday, November 25, 2003, at 06:50  PM, Jon Pipitone wrote:
> When I switched over to Lucene 1.3 RC2 I found that a user of my 
> application could create an unhandled exception, just by entering in a 
> wild card query.  (There was a post today about this [1]).
> The exception being thrown when a wildcard query causes a BooleanQuery 
> to grow too large, BooleanQuery$TooManyClauses, extends 
> RuntimeException.  As such, the method throwing it -- 
> BooleanQuery.add() -- doesn't need to declare that it throws it, nor 
> if it did would there be any compilation errors if the caller does not 
> catch it.
> My application was using QueryParser as before, and there were no 
> compile time errors to indicate that I would need to catch this sort 
> of exception.  Of course, it is in the javadoc (but of BooleanQuery 
> not QueryParser).
> My question is, if throwing BooleanQuery$TooManyClauses is part of the 
> API (which it seems like it is implicitly) then shouldn't it be 
> enforced at compile time? What about wrapping this sort of exception 
> in a ParseException so that it can be handled like all other parse 
> exceptions?

I concur and have just modified QueryParser to throw a ParseException 
instead when a TooManyClauses exception is thrown.  I checked the 
codebase for any other custom Errors/Exceptions and don't see any 
others that would be thrown so I think we've got the bases covered in 
QueryParser now.  You could still get some other type of 
RuntimeException if things went haywire somewhere under the covers, but 
this is a more or less expected exception that makes sense to catch as 
a ParseException for nicer handling by a UI.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message