| 312 | } |
| 313 | |
| 314 | HRESULT PyCom_SetCOMErrorFromSimple(HRESULT hr, REFIID riid /* = IID_NULL */, const char *description /* = NULL*/) |
| 315 | { |
| 316 | // fast path... |
| 317 | if ( hr == S_OK ) |
| 318 | return S_OK; |
| 319 | |
| 320 | // If you specify a description you should also specify the IID |
| 321 | assert(riid != IID_NULL || description==NULL); |
| 322 | // Reset the error info for this thread. "Inside OLE2" says we |
| 323 | // can call IErrorInfo with NULL, but the COM documentation doesnt mention it. |
| 324 | BSTR bstrDesc = NULL; |
| 325 | if (description) bstrDesc = PyWin_String_AsBstr(description); |
| 326 | |
| 327 | EXCEPINFO einfo = { |
| 328 | 0, // wCode |
| 329 | 0, // wReserved |
| 330 | NULL, // bstrSource |
| 331 | bstrDesc, // bstrDescription |
| 332 | NULL, // bstrHelpFile |
| 333 | 0, // dwHelpContext |
| 334 | NULL, // pvReserved |
| 335 | NULL, // pfnDeferredFillIn |
| 336 | hr // scode |
| 337 | }; |
| 338 | HRESULT ret = PyCom_SetCOMErrorFromExcepInfo(&einfo, riid); |
| 339 | PyCom_CleanupExcepInfo(&einfo); |
| 340 | return ret; |
| 341 | } |
| 342 | |
| 343 | PYCOM_EXPORT HRESULT PyCom_SetCOMErrorFromPyException(REFIID riid /* = IID_NULL */) |
| 344 | { |
no test coverage detected