>I'm not sure if what I propose is a good idea, and I'm
>happy to be told no, but I thought I'd mention it anyway.
>I'm doing some embedding, and executing user scripts from a
>When I get an exception, I want to display a simple
>summary, without the traceback, i.e. something along the
>I've found that the Py.formatException creates exactly the
>format I want. But that method is not public, so it can't
>be accessed outside the jython package.
>What I'm doing for now is simply copying the code for the
>formatException method and pasting it inside my own code.
>However, this is unsatisfactory, since it could lead to
>that code breaking in future versions of jython if the
>structure of exceptions changes.
>So, would it be a good idea to make Py.formatException
This code is normally accessed from the traceback module,
so you might consider using the traceback module in
java code along the following lines (untested):
intrpr = org.python.util.PyInterpreter();
String result = intrpr.eval('traceback.formatException(excp)').toString();
/* I don't remember the except function name in the traceback module,
* but you get the idea.
It's a slow detour, but at least it's future proof.
Make sure to test it, though. It's not nice to have to fix this
the first time some production code throws and exception...
I wouldn't mind Py.formatException to be public, but
that would carry some weight in maintaining.