COM question
Mark Hammond
MHammond at skippinet.com.au
Mon May 31 19:01:00 EDT 1999
Gaetan Corneau wrote in message
<816010E2456BD111A48700805FBBE2EEFDF2D1 at ex-quebec-u1.baan.com>...
>Hello,
>
>I was told that in Visual Basic, there is object called "Err" I can access
>to retrieve error messages.
>Is that object (or an equivalent) accessible in Python? Or do I just catch
>an exception and question it? If so, what exception do I catch?
>
You catch:
except pythoncom.com_error, (hr, desc, exc, argErr):
In this case, "desc" describes the hr - ie, is likely to be a generic
message. The specific info is in the exc tuple (if not None):
wCode, source, desc, helpfile, helpcontext, scode = exc
source desc, helpfile are strings. "desc" is the item you are after if it
exists.
Eg, here is what I use:
def get_msg(exc_info):
hr, msg, exc, arg = exc_info
if exc and exc[2]:
return exc[2]
return msg
Mark.
More information about the Python-list
mailing list