MCPcopy Create free account
hub / github.com/mhammond/pywin32 / PyCom_BuildPyExceptionFromEXCEPINFO

Function PyCom_BuildPyExceptionFromEXCEPINFO

com/win32com/src/ErrorUtils.cpp:619–656  ·  view source on GitHub ↗

Uses the HRESULT and an EXCEPINFO structure to create and set a pythoncom.com_error. Used rarely - currently by IDispatch and IActiveScriptParse* interfaces.

Source from the content-addressed store, hash-verified

617// set a pythoncom.com_error.
618// Used rarely - currently by IDispatch and IActiveScriptParse* interfaces.
619PyObject* PyCom_BuildPyExceptionFromEXCEPINFO(HRESULT hr, EXCEPINFO *pexcepInfo /* = NULL */, UINT nArgErr /* = -1 */)
620{
621 TCHAR buf[512];
622 GetScodeString(hr, buf, sizeof(buf)/sizeof(TCHAR));
623 PyObject *obScodeString = PyWinObject_FromTCHAR(buf);
624 PyObject *evalue;
625 PyObject *obArg;
626
627 if ( nArgErr != -1 ) {
628 obArg = PyInt_FromLong(nArgErr);
629 } else {
630 obArg = Py_None;
631 Py_INCREF(obArg);
632 }
633 if (pexcepInfo==NULL)
634 {
635 evalue = Py_BuildValue("iOzO", hr, obScodeString, NULL, obArg);
636 }
637 else
638 {
639 PyObject *obExcepInfo = PyCom_PyObjectFromExcepInfo(pexcepInfo);
640 if ( obExcepInfo )
641 {
642 evalue = Py_BuildValue("iOOO", hr, obScodeString, obExcepInfo, obArg);
643 Py_DECREF(obExcepInfo);
644 }
645 else
646 evalue = NULL;
647
648 /* done with the exception, free it */
649 PyCom_CleanupExcepInfo(pexcepInfo);
650 }
651 Py_DECREF(obArg);
652 PyErr_SetObject(PyWinExc_COMError, evalue);
653 Py_XDECREF(evalue);
654 Py_XDECREF(obScodeString);
655 return NULL;
656}
657
658PyObject* PyCom_BuildInternalPyException(char *msg)
659{

Callers 4

HandledDispatchFailureFunction · 0.85
AddScriptletMethod · 0.85
ParseScriptTextMethod · 0.85
OleSetADSIErrorFunction · 0.85

Calls 4

PyCom_CleanupExcepInfoFunction · 0.85
GetScodeStringFunction · 0.70
PyWinObject_FromTCHARFunction · 0.50

Tested by

no test coverage detected