Thanks for the hint.

After some digging, this is what I found that works

<code>
            excp.normalize();
            PyObject lineno = excp.value.__findattr__("lineno");
            PyObject offset = excp.value.__findattr__("offset");
            PyObject message = excp.value.__findattr__("msg");
            if(lineno==null || offset==null || message==null) {
                System.out.println("line number   = " + excp.traceback.tb_lineno);
                System.out.println("error message = " + excp.value.__str__());
            } else {
                System.out.println("line number   = " + lineno);
                System.out.println("column number = " + offset);
                System.out.println("Error message = " + message);
            }
</code>

I still need to keep testing to make sure that I can always capture the error (line number and message string) correctly.

Any recommendation on how to make the above code more robust and fail-safe is appreciated.

Thanks again. :)


On Mon, Mar 8, 2010 at 11:38 AM, Jeff Emanuel <jemanuel@frii.com> wrote:
That is what he is saying.  Those attributes are populated
only for SyntaxError.  For other exception types,
the best you can do now is work with the exception's
traceback field.


Santosh Tiwari wrote:

Thanks for the reply.

Can you elaborate?

Are you saying that the following code fragment

<code>
excp.normalize();
PyObject lineno = excp.value.__findattr__("lineno");
PyObject offset = excp.value.__findattr__("offset");
PyObject message = excp.value.__findattr__("msg");
</code>

will not work all the time. In fact, it does not in some cases. I need a remedy so that the above code (or something else) works always (all the time).

Thanks again.



2010/3/5 Alex Grönholm <alex.gronholm@nextday.fi <mailto:alex.gronholm@nextday.fi>>


   The Jython interpreter does not fill in these fields at the moment.
   That is one of the problems I'd like to get addressed for 2.5.2.
   The reason you are getting those in the first instance is probably
   because there is a syntax error there, and the code isn't even
   executed yet.


------------------------------------------------------------------------


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev


------------------------------------------------------------------------

_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users



--
Santosh Tiwari
tiwaris@gmail.com