STDMETHODIMP nsXPCDispTestMethods::CreateError() { CComBSTR someText(L"CreateError Test"); ICreateErrorInfo * pCreateError; IErrorInfo * pError; HRESULT result = CreateErrorInfo(&pCreateError); if (FAILED(result)) return E_NOTIMPL; result = pCreateError->QueryInterface(&pError); if (FAILED(result)) return E_NOTIMPL; result = pCreateError->SetDescription(someText); if (FAILED(result)) return E_NOTIMPL; result = pCreateError->SetGUID(IID_nsIXPCDispTestMethods); if (FAILED(result)) return E_NOTIMPL; CComBSTR source(L"XPCIDispatchTest.nsXPCDispTestMethods.1"); result = pCreateError->SetSource(source); if (FAILED(result)) return E_NOTIMPL; result = SetErrorInfo(0, pError); if (FAILED(result)) return E_NOTIMPL; pError->Release(); pCreateError->Release(); return E_FAIL; }
/** * Sets the COM error from a result code and text message * @param hResult the COM error code to be used * @param message the message to put in the error * @return the error code passed in via hResult */ inline HRESULT Error(HRESULT hResult, const char * message) { CComBSTR someText(message); return Error(hResult, someText); }