#101 closed defect (released)
Query parser throws raw strings as exceptions
Reported by: | Richard Boulton | Owned by: | Olly Betts |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Library API | Version: | SVN trunk |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | All |
Description
At line 131 of the query parser, the query parser throws an plain std::string as an exception. This should probably be wrapped in a subclass of Xapian::Error, so that applications can catch all Xapian errors using "catch Xapian::Error".
One particular problem this causes is with the SWIG bindings, which catch only Xapian::Error subclasses. As a result, the message from a queryparser error is thrown away, and replaced with "unknown error in Xapian".
Change History (6)
comment:1 by , 18 years ago
op_sys: | Linux → All |
---|---|
rep_platform: | PC → All |
Status: | new → assigned |
comment:2 by , 18 years ago
I've added a catch() to the SWIG bindings so that they report the error string, rather than "unknown error in Xapian" for these errors. I agree that this should be fixed for 1.0 (at which point this catch() clause could be removed).
comment:3 by , 18 years ago
I think we should anticipate how this will be fixed in 1.0 and make it so the exception string is something like:
"QueryParserError: " + str
instead of just:
str
That way user code in scripting languages won't need to change at all for this change in 1.0 (user C++ code will need to change slightly of course).
It would also be good to have a test for this in the smoketest for languages where it's possible (it probably isn't really for PHP4).
comment:4 by , 18 years ago
Actually, the exception thrown is "const char *", not "std::string" so your change doesn't make any difference - an excellent demonstration of why we really should add test cases wherever possible!
I've fixed this and added the "QueryParserError: " prefix, and added a testcase for both PHP4 (turns out it is possible) and PHP5.
Equivalent tests for other languages would still be nice though.
comment:6 by , 18 years ago
Operating System: | → All |
---|---|
Resolution: | fixed → released |
Fixed in 1.0.0 release.
Line 131 of queryparser/queryparser.cc
This is a hang over from when queryparser was just part of Omega. I meant to change this when the QueryParser API was overhauled, but obviously I didn't!
I guess it would be reasonable to fix this in 1.0.