Catching a pywintypes.api_error excpeption?
peter at engcorp.com
Fri Aug 2 13:49:39 CEST 2002
Derek Basch wrote:
> Can someone tell me how to catch this exception with a
> try, except clause:
> SetCommState(self.handle, dcb)
> pywintypes.api_error: (87, 'SetCommState', 'The
> parameter is incorrect.')
> every exception I have previously worked with has been
> a class such as IOError. How do i catch this one?
As with "except IOError", just use the name of the class:
print 'spam spam spam spam'
(Although this sounds more like an exception coming from
a bug, not a runtime condition that you would want to catch
like an IOError.)
More information about the Python-list