Andi Vajda <va...@apache.org> wrote: > On Sep 25, 2010, at 13:54, Bill Janssen <jans...@parc.com> wrote: > > > I've got a subclass of PythonMultiFieldQueryParser. I'd like to be > > able > > to throw a custom Python exception with parameters in that code, and > > catch it in the Python code that's using it. To do this, the > > exception > > has to somehow travel through Java. I thought I could perhaps > > subclass > > PythonException to do this, but it looks like that's not really an > > extension class. > > > > How to do this? > > Have you tried just throwing your exception ? It should be picked up > at the JVM crossing point and thrown on in some form back to Python, > no ?
Yep, it shows up again in Python as a JavaError, but the error type and any arguments associated with it have been stripped out. I'm trying to use it to communicate a really exceptional condition, and I need that info. What I'm doing now is setting the message of the Python exception to a particular string, then using an RE in the higher-level Python caller to see if that funky string is present in the text of the JavaError. If it is, I scrape the value out of that text. Would be nice to have a more hygienic approach :-). Bill