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!
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to