Awesome, worked like a charm. Thanks
On Thu, May 27, 2010 at 9:54 AM, Jeff Emanuel <jem...@fr...> wrote:
>
> Ok,
>
> MyExceptionThrower.java:
>
> public class MyExceptionThrower {
>
> private static PyObject MyException;
> public static init(PyObject dict) {
> MyException = Py.makeClass("MyException",
> new PyObject[]{Py.RuntimeError}, new PyStringMap());
> dict.__setitem__("MyException",MyException);
> }
>
> public static void toss() {
> throw new PyException(MyException,message);
> }
>
>
> import MyExceptionThrower
> MyExceptionThrower.init(globals())
> try:
> MyExceptionThrower.toss()
> except MyException, e:
> print e
>
>
>
>
>
> Brandon Pedersen wrote:
>>
>> Ok, I guess I should have mentioned that I also want to handle:
>>
>> try:
>> something that raises my exception
>> except MyException, e:
>> ....
>>
>> as well as catching RuntimeError
>>
>> Thanks,
>>
>> -Brandon
>>
>> On Wed, May 26, 2010 at 1:56 PM, Jeff Emanuel <jem...@fr...> wrote:
>>>
>>> MyExceptionThrower.java:
>>> public class MyExceptionThrower {
>>> public static void toss() {
>>> throw org.python.core.Py.RuntimeError("my exception");
>>> }
>>> }
>>>
>>> import MyExceptionThrower
>>> try:
>>> MyExceptionThrower.toss()
>>> except RuntimeError, e:
>>> print e
>>>
>>>
>>>
>>> Brandon Pedersen wrote:
>>>>
>>>> Hey,
>>>>
>>>> If I want to create an exception type in Java that is available in a
>>>> jython script and is a subclass of RuntimeError, how would I do that?
>>>>
>>>> so,
>>>>
>>>> try:
>>>> something that raises my exception type
>>>> except RuntimeError, e:
>>>> ....
>>>>
>>>> would work
>>>>
>>>> Thanks,
>>>>
>>>> -Brandon
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> Jython-users mailing list
>>>> Jyt...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/jython-users
>
|