4

I am writing an app that interacts with Excel. However, I'm hitting an error that I can't track down. My traceback says:

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)

Using the com_error documentation, I can figure out most of this. However, I can't figure out how to read the interior tuple. The docs refer to this as an (optional) excepinfo tuple, but they don't describe what the contents of it are.

indigochild
  • 350
  • 1
  • 5
  • 21

1 Answers1

3

From https://msdn.microsoft.com/en-us/library/windows/desktop/ms221133(v=vs.85).aspx

typedef struct tagEXCEPINFO {
  WORD    wCode;
  WORD    wReserved;
  BSTR    bstrSource;
  BSTR    bstrDescription;
  BSTR    bstrHelpFile;
  DWORD   dwHelpContext;
  PVOID   pvReserved;
  HRESULT (__stdcall *pfnDeferredFillIn)(struct tagEXCEPINFO*);
  SCODE   scode;
} EXCEPINFO, *LPEXCEPINFO;

Examining a com_error output that was generated by one of my applications, I would think that the excepinfo tuple maps to (wCode, bstrSource, bstrDescription, bstrHelpFile, dwHelpContext, scode)

Admittedly, I didn't bother to go hunting in pywin32 sources to find where the tuple is constructed.

paulluap
  • 313
  • 4
  • 14
  • `pywin32` sources for `PyCom_PyObjectFromExcepInfo` [here](https://github.com/mhammond/pywin32/blob/cacb1ab5fbddaf1a275e741a76d987170c3504f5/com/win32com/src/ErrorUtils.cpp#L680-L686) confirm that you are right paulluap. The tuple does indeed map to `(wCode, bstrSource, bstrDescription, bstrHelpFile, dwHelpContext, scode)` – Day Dec 18 '17 at 21:57