[Tutor] errno vs. sys.exc_info
doug shawhan
doug.shawhan at gmail.com
Fri Jun 9 17:46:25 CEST 2006
I am in need of a clear way to return exceptions within a try loop.
I have been looking at both errno and sys.exc_info. I know that using errno
is not encouraged in threaded programs, but this is no big deal for my
purposes.
I found a good, clear example for translating the rather cryptic output from
sys.exc_info:
def formatExceptionInfo(maxTBlevel=5):
cla, exc, trbk = sys.exc_info()
excName = cla.__name__
try:
excArgs = exc.__dict__["args"]
except KeyError:
excArgs = "<no args>"
excTb = traceback.format_tb(trbk, maxTBlevel)
return (excName, excArgs, excTb)
Which seems to cover most of the bases, but I have yet to find a good
example of using errno.
Can someone provide a quick cut? :-)
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060609/be906a2c/attachment.htm
More information about the Tutor
mailing list