Message11690

Author jamesmudd
Recipients jamesmudd
Date 2017-12-08.13:18:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512739099.01.0.213398074469.issue2650@psf.upfronthosting.co.za>
In-reply-to
Content
When a PyException is created the detailMessage field of the Java exception is not filled in. This is probamatic when you use a Java logging framework and a PyException is caught. The detailMessage is used to build the logging output by calling e.getMessage() on the exception.

See the attached Main.java code which illiterates the issue. The output is:
    Exception happened in script: null
    Exception happened in script: NameError: name 's' is not defined in <script> at line number 1

It also shows how this is handled differently if using the python script engine. There the message is filled by calling Py.formatException(type, value) when the ScriptException is constructed.

I propose this could be added to the PyException constructor to initialise the detailMessage, I will create a pull request to do that.

In general though I think it might be better to refactor PyException to be immutable, which make sense for an Exception as it should capture the state when its thrown and can't be modified after that. I will look into that as a separate pull request.
History
Date User Action Args
2017-12-08 13:18:19jamesmuddsetrecipients: + jamesmudd
2017-12-08 13:18:19jamesmuddsetmessageid: <1512739099.01.0.213398074469.issue2650@psf.upfronthosting.co.za>
2017-12-08 13:18:18jamesmuddlinkissue2650 messages
2017-12-08 13:18:17jamesmuddcreate