title: How to catch these exceptions individually?
body: <p>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:</p>
  
  <pre><code>pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'QBXMLRP2.RequestProcessor.2', 'The QuickBooks company data file is currently open in a mode other than the one specified by your application.', None, 0, -2147220464), None)
  
  pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'QBXMLRP2.RequestProcessor.2', 'Could not start QuickBooks.', None, 0, -2147220472), None)
  </code></pre>
  
  <p>Catching the generic exception with <code>except Exception as e</code> shows that the type of <code>e</code> is <code>&lt;class 'pywintypes.com_error'&gt;</code>, which cannot be used to catch an exception:</p>
  
  <pre><code>... catch pywintypes.com_error as e:
  NameError: global name 'pywintypes' is not defined
  </code></pre>
  
  <p><strong>So how might I catch these two exceptions in a non-generic manner?</strong> Ideally the code would have this layout:</p>
  
  <pre><code>try:
      qb = qbsdk_interface.Qbsdk_Interface(QB_FILE)
  
  except QbWrongModeError as e:
      print('Quickbooks is open in the wrong mode!')
  
  except QbClosedError as e:
      print('Quickbooks is closed!')
  
  except Exception as e:
      print('Something else went wrong!')
  </code></pre>
  
  <p>Of course, the exceptions <code>QbWrongModeError</code> and <code>QbClosedError</code> do not exist, so what should be there in their place?</p>