How to identify user defined Python exception in Java (Jython)?
Peter Lorenzen
oracle_vs_ms at yahoo.dk
Fri Nov 8 08:39:57 EST 2002
Hi,
I have defined my own EtError exception like this:
interp.exec
( "class EtError(Exception): \n"+
" def __init__(self, value): \n"+
" self.value = value \n"+
" def __str__(self): \n"+
" return `self.value` \n"
);
I throw it here:
interp.exec
( "def pow(*args): \n"+
" if len(args) != 2: \n"+
" raise EtError('powError') \n"+
" return __builtin__.pow(*args) \n"
);
In my Java program I catch a PyException. I can catch Py.SyntaxError
and Py.NameError fine. But when I catch my own EtError I have no way
of identify it. In value I get ‘org.python.core.PyInstance at 2f60ce' not
‘powError' as I expected and getMessage/text is null. How do I
identify my exception? Does anybody know?
Regards,
Peter Lorenzen
More information about the Python-list
mailing list