[python-win32] How to catch a COM error

Gregory Piñero gregpinero at gmail.com
Tue Jan 10 17:30:59 CET 2006


Hi guys,

This is a silly question but how do I capture a com_error from another
module?  Below is the code I'm trying but it's not working.  I get
this error:
Traceback (most recent call last):
...
    except com_error:
NameError: name 'com_error' is not defined

<code>
        import module_that_uses_com
        try:
            module_that_uses_com.main(False) #Production
        except com_error:
            #sometimes QB throws an error for no good reason
            #so many times if we wait it gets better.
            #>Is this the correct error to capture?
            time.sleep(600) #10 min
            module_that_uses_com.main(False)
</code>

Much thanks!

--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)


More information about the Python-win32 mailing list