Discussion:
[comtypes-users] How to handle a COM library exception?
Andy K.
2014-12-10 12:21:36 UTC
Permalink
Hello all,

I'm using a COM library through comtypes and I'd like to add exception
handling to my code. Reading through this group I've understood
comtypes is supposed to raise the COMError exception if something is
wrong with the library. Is this correct?

Here is how I'm trying to handle it:

# "piSeman" is an object created with comtypes.client.CreateObject()
try:
n = piSeman.Nodes[-1] # index cannot be less than 0, so it's a mistake
except COMError:
print('Error')
sys.exit()
Problem Event Name: BEX
Application Name: python.exe
Application Version: 0.0.0.0
Application Timestamp: 53e3ddb5
Fault Module Name: seman.dll
Fault Module Version: 1.0.0.1
Fault Module Timestamp: 5449a83e
Exception Offset: 00242e0a
Exception Code: c0000417
Exception Data: 00000000
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1049
Additional Information 1: 9604
Additional Information 2: 96043c98bcbd85604ce467a759e6fd1e
Additional Information 3: 8b44
Additional Information 4: 8b44ac3c9f876fe8047d534ff86187a6
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our
C:\Windows\system32\en-US\erofflps.txt
I'm using comtypes 1.1.1 and python 3.4.1 on Windows 7.

Could anyone please give me some direction?
--
Best,
Andy
Loading...