[Xapian-discuss] Re: queryparser dies badly on double search
words.
Olly Betts
olly at survex.com
Tue Aug 30 12:15:42 BST 2005
On Mon, Aug 22, 2005 at 06:18:53PM +0200, R. Mattes wrote:
> Well, i did some more testing and it seems that these malformed query
> strings trigger an exception that can only be cought by
> catch (...) {
> Hmm, looking at the sources in xapian-core/queryparser it _seems_ like
> the parser would only throw an exception of type (char *) but a handler
> like: catch(char *mesg) doesn't catch that exception
The exception type thrown is "const char *", which won't be caught by a
handler for "char *". If you use "catch (const char *mesg)" instead it
should be caught.
This is a bug in the XS glue - it should be catching this exception.
(Untested) patch attached.
We probably shouldn't be throwing naked "const char *" either - it would
be more in keeping with the rest of the API to throw
Xapian::QueryParserException or similar.
> i wonder whether qeryparser throws internal->errmsg while it's still
> at it's initial value of NULL ...
In C++, NULL isn't a special type (unlike some other languages).
Throwing a pointer which has been assigned the value NULL will still
throw an exception of the type of the pointer.
Cheers,
Olly
-------------- next part --------------
Index: XS/QueryParser.xs
===================================================================
--- XS/QueryParser.xs (revision 30)
+++ XS/QueryParser.xs (working copy)
@@ -50,8 +50,13 @@
QueryParser::parse_query(q)
string q
CODE:
- RETVAL = new Query();
- *RETVAL = THIS->parse_query(q);
+ try {
+ RETVAL = new Query();
+ *RETVAL = THIS->parse_query(q);
+ }
+ catch (const char * err_msg) {
+ croak( "Exception: %s", err_msg );
+ }
OUTPUT:
RETVAL
More information about the Xapian-discuss
mailing list