[Xapian-discuss] Bug in error handling for QueryParser in PHP
Olly Betts
olly@survex.com
Thu, 27 May 2004 18:03:49 +0100
On Thu, May 27, 2004 at 05:35:22PM +0100, James Aylett wrote:
> Are you proposing dropping exception usage for the query parser?
Yes (at least externally - internally I think we may need to throw and
catch to escape the parser, but I'll have to look more closely to be
sure).
> I'm in favour of that. I'd be inclined to return non-zero on error,
> because that's more Unix-like, but that's a minor issue.
Though true/false is more C++.
But parse_query() already has a return type - Xapian::Query.
The most natural solution would probably be to return an empty query
(made using Xapian::Query()) in this case. The difference between
"no query" and "query parse error" is what the "last error" function
returns. You can usefully think of "no query" as a special error
condition.
And I think the "reparse a bad query" code should perhaps be an explicit
separate mode - then the developer can control reparsing by checking for
a parse error, and reparsing with a different mode. The modes might be
"boolean" (what we have at present), "probabilistic" (no AND, OR, etc),
"pasted text" (no operators at all).
Cheers,
Olly