com_error

ramesh4954 at my-deja.com ramesh4954 at my-deja.com
Mon Sep 11 09:12:54 EDT 2000


Thanks very much Alex, for the timely help.

K. Ramesh

In article <8peer301v88 at news1.newsguy.com>,
  "Alex Martelli" <aleaxit at yahoo.com> wrote:
> <ramesh4954 at my-deja.com> wrote in message
> news:8pe2u8$9sl$1 at nnrp1.deja.com...
> > How do I get the actual error message from a com_error? When I try
to
> > print the details I get the following :
> > <pywintypes.com_error instance at 902e60>
> >
> > Any help would be appreciated. Thanks
>
> Use the .args member of the error object.  Example:
>
> >>> import pywintypes
> >>> import win32com.client
> >>> try: foo=win32com.client.Dispatch("Not.There")
> ... except pywintypes.com_error, erob: print 'caught'
> ...
> caught
> >>> erob
> <pywintypes.com_error instance at 14ca800>
> >>> print erob
> (-2147221005, 'Invalid class string', None, None)
> >>> dir(erob)
> ['args']
> >>> erob.args
> (-2147221005, 'Invalid class string', None, None)
> >>> erob.args[0]
> -2147221005
> >>> erob.args[1]
> 'Invalid class string'
> >>>
>
> Alex
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list