How to get a raised exception from other thread
peter at engcorp.com
Fri Oct 21 12:38:19 CEST 2005
> Ok, sorry about the above question. I solved it adding this to the main
> SrvrTCP = module.ThreadedTCPServer(ip,port)
> except Exception, description:
> Error:\n\n"+str(description),title="TCPServer",style=wx.OK |
> Peter, thank you very much.
You're quite welcome. It's nice to be able to provide a "perfect"
answer, for a change. :-)
One suggestion about the above: "description" is actually the exception
instance (the object), not just the description. The except statement
can take two items after: the exception type(s) to catch and,
optionally, a name to bind to the exception instance. But since
exception objects know how to represent themselves as strings, calling
str() on it gives you the description you wanted. Therefore it would be
more readable/correct to say this:
except Exception, ex:
MsgBox(..... str(ex) ... )
But I'm happy it works either way!
More information about the Python-list