Discussion:
[python-win32] How to catch a COM error
Gregory Piñero
2006-01-10 16:30:59 UTC
Permalink
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)
Gregory Piñero
2006-01-10 18:53:24 UTC
Permalink
Just wanted to check if this made it to you guys? Not because I'm
impatient, just that some of my emails haven't been making to the list
lately.

-Greg
Post by Gregory Piñero
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
...
NameError: name 'com_error' is not defined
<code>
import module_that_uses_com
module_that_uses_com.main(False) #Production
#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)
--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)
Mark Hammond
2006-01-10 22:40:45 UTC
Permalink
Post by Gregory Piñero
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
...
NameError: name 'com_error' is not defined
com_error is in the pythoncom module. So you want:

import pythoncom
...
try:
...
except pythoncom.com_error:
...

Mark

Loading...