[IronPython] Exception.StackTrace gone?
Dino Viehland
dinov at exchange.microsoft.com
Thu Feb 9 18:46:06 CET 2006
The fact that you can access this via exc_value.StackTrace is actually a bug - and one that's already fixed internally for our next release. So for now using the clsException field is the better way to go.
Another alternative here is that you can also explicitly catch a CLS exception. Eg:
import System
try:
...
except System.Exception, e:
...
and we'll actually give you an instance of a CLR exception (with StackTrace) rather than a Python Exception class. The underlying theme here is that we give you what you ask for>
And finally the BEST mechanism is obviously sys.exc_traceback / sys.exc_info()[2] for compatibility with CPython. But unfortunately we just haven't implemented this yet. We have a bug for 1.0 on this so it should be fixed during one of the upcoming betas.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of J. de Hooge
Sent: Thursday, February 09, 2006 6:34 AM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] Exception.StackTrace gone?
Works like a charm. Thanks!
Jacques
-----Oorspronkelijk bericht-----
Van: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] Namens Jonathan Jacobs
Verzonden: Thursday, February 09, 2006 1:19 PM
Aan: Discussion of IronPython
Onderwerp: Re: [IronPython] Exception.StackTrace gone?
J. de Hooge wrote:
> Does anyone know why it fails, and, more important, how I still can
> print a stack trace?
You could either use sys.exc_value or .clsException.StackTrace on
Exception objects. I don't know if the latter is a reliable source.
>>> import sys
>>> try:
.. raise NotImplementedError
.. except Exception, e:
.. print e.clsException.StackTrace
.. print '*****'
.. print sys.exc_value.StackTrace
..
at IronPython.Runtime.Ops.Raise(Object type, Object value, Object
traceback)
at input##25(Frame )
*****
at IronPython.Runtime.Ops.Raise(Object type, Object value, Object
traceback)
at input##25(Frame )
>>>
Hope this helps.
--
Jonathan
When you meet a master swordsman,
show him your sword.
When you meet a man who is not a poet,
do not show him your poem.
-- Rinzai, ninth century Zen master
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list