[pylucene-dev] Re: ParseException support?
Andi Vajda
vajda at osafoundation.org
Fri Feb 11 11:41:30 PST 2005
I just checked in code that adds support for java::lang::Throwable and that
propagates Java exceptions to python via a wrapping JavaError.
For example:
from PyLucene import IndexReader, JavaError
# Try to delete a non-existent document.
reader = IndexReader.open(store)
try:
reader.deleteDocument(0)
except JavaError, e:
print e
Andi..
On Thu, 10 Feb 2005, Andi Vajda wrote:
>
> And now to your question :)
>
> Yes, exception reporting needs some work. I've been keeping this in mind and
> should have a solution soonish. The stack traces are a debugging 'feature'
> that is rarely usable or available anyway.
>
> I need to change the error reporting so that the various pieces of the
> exception are segregated so that applications can choose to display whichever
> they think is relevant.
>
> Andi..
>
> On Thu, 10 Feb 2005, Vaclav Slavik wrote:
>
>> Hi,
>>
>> and the reason for rejection is...?
>>
>> Thanks,
>> Vaclav
>>
>> pylucene-dev-owner at osafoundation.org wrote:
>>> You are not allowed to post to this mailing list, and your message
>>> has been automatically rejected. If you think that your messages
>>> are being rejected in error, contact the mailing list owner at
>>> pylucene-dev-owner at osafoundation.org.
>>>
>>>
>>> Hi,
>>>
>>> I'm using PyLucene in Documancer (http://documancer.sf.net) with
>>> great success. There's a small but annoying problem, though: I'm
>>> unable to retrieve human-readable information about QueryParser
>>> exceptions. In Documancer, the user directly enters the query and I
>>> want to display error message when Lucene chokes on it.
>>> Unfortunately I only get a
>>>
>>> generic ValueError exception with backtrace being its string:
>>>>>> import PyLucene
>>>>>> PyLucene.QueryParser.parse('*t','c',None)
>>>
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in ?
>>> ValueError: org.apache.lucene.queryParser.ParseException: Lexical
>>> error at line 1, column 1. Encountered: "*" (42), after : ""
>>> at
>>> org.apache.lucene.queryParser.QueryParser.parse(java.lang.String)
>>> (/usr/lib/python2.3/site-packages/_PyLucene.so)
>>> at
>>> org.apache.lucene.queryParser.QueryParser.parse(java.lang.String,
>>> java.lang.String, org.apache.lucene.analysis.Analyzer)
>>> (/usr/lib/python2.3/site-packages/_PyLucene.so)
>>> at PyCFunction_Call (/usr/lib/libpython2.3.so.1.0)
>>> at PyEval_EvalCodeEx (/usr/lib/libpython2.3.so.1.0)
>>> at PyEval_EvalCode (/usr/lib/libpython2.3.so.1.0)
>>> at PyRun_InteractiveOneFlags (/usr/lib/libpython2.3.so.1.0)
>>> at PyRun_InteractiveLoopFlags (/usr/lib/libpython2.3.so.1.0)
>>> at PyRun_AnyFileExFlags (/usr/lib/libpython2.3.so.1.0)
>>> at Py_Main (/usr/lib/libpython2.3.so.1.0)
>>> at main (/home/vasek/devel/documancer/code/src/python)
>>> at __libc_start_main (/lib/libc-2.3.3.so)
>>> at _start (Unknown Source)
>>>
>>> Obviously, the only interesting piece for the user is the part that
>>> corresponds to ParseException.getMessage():
>>> Lexical error at line 1, column 1. Encountered: "*" (42), after :
>>> ""
>>>
>>> Would it be hard to modify PyLucene to either not include the
>>> backtrace verbatim as exception's string or to raise distinct
>>> PyLucene.ParseException exception that would contain the message as
>>> its attribute?
>>>
>>> Thanks,
>>> Vaclav
>> --
>> PGP key: 0x465264C9, available from http://wwwkeys.pgp.net/
>>
>
More information about the pylucene-dev
mailing list