2

Python and Jython newbie here.

I am passably familiar with how to raise exceptions in normal Python.

However, in the Jython environment I find myself in (WLST), if I do:

raise Exception("hello") 

...then it appears to raise a java.lang.Exception:

wls:/offline> raise Exception("hello") Traceback (innermost last): File "<console>", line 1, in ? at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) java.lang.Exception: java.lang.Exception: hello wls:/offline> 

How can I raise a Python Exception in this environment? Or, at least: why is it a java.lang.Exception that is raised here?

1 Answer 1

1

For posterity, I can do this:

from exceptions import Exception as PythonException 

Then I can do this:

raise Exception('This will be a java.lang.Exception.') raise PythonException('This will be a "native" Python exception.') 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.