|
From: brian z. <bz...@zi...> - 2001-02-19 02:44:24
|
I have implemented a few extension modules in Java to be used in the Jython runtime. I have a good feel for most of the requirements of doing such except for the area of exceptions. I have seen a couple different ways to create and raise exceptions and I wanted to know if there was a standard, or least best practices approach. I've noticed that Py.java and Finn's cPickle module have written the exception class hierarchy in Python (as opposed to Java) and then used jpythonc to produce the classes so they would be available in Java. I've never felt comfortable checking in generated source. On the other hand, some modules, mine included, have used a static PyString and use PyException's constructor to make the exception. This seems weak to me as I'm not really subclassing the exception, just giving it a type. I'd rather have a more OO feel by subclassing the exception, but I haven't seen this done anywhere except for PySyntaxError. I'm opened to any ideas. I am partial to subclassing PyException as this seems the most correct, but since so few examples exist of such being done I'd like to find out why? I think the Py.makeException() methods would be useful but they don't allow the specification of a superclass. Anyways, sorry to ramble, but I've been confused about exceptions in Jython for some time. thanks, brian |