I am writing a Python program that interfaces with Quickbooks. When connecting to Quickbooks, depending on the problem, I might get one of two common exceptions:
Now pywintypes.error
is BaseException
.
There is no need to from pywintypes import com_error
.
If you want to catch this exception.
You can just catch BaseException
except BaseException as e: # to catch pywintypes.error
print(e.args)
the exception's format likes this:
(0, 'SetForegroundWindow', 'No error message is available')
So If you want to examine the return code,use e.args[0]
instead of e.exceptinfo[5]