本文整理汇总了C++中IErrorInfo类的典型用法代码示例。如果您正苦于以下问题:C++ IErrorInfo类的具体用法?C++ IErrorInfo怎么用?C++ IErrorInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IErrorInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateComErrorInfo
// The CreateComErrorInfo function uses CreateErrorInfo to create error
// object, which is then filled with the error information and passed to
// the acceptor by a call to SetErrorInfo.
void CreateComErrorInfo(const char* description, const char* source,
const char* helpFile, UInt32 helpContext)
{
ICreateErrorInfo* createErrInfo;
IErrorInfo* errInfo;
std::basic_string<wchar_t> buf;
if (CreateErrorInfo(&createErrInfo) == S_OK)
{
createErrInfo->SetGUID(IID_IErrorInfo);
if (description != NULL)
{
buf = WideStringFromMultiByteString(description);
createErrInfo->SetDescription(const_cast<wchar_t*>(buf.c_str()));
}
if (source != NULL)
{
buf = WideStringFromMultiByteString(source);
createErrInfo->SetSource(const_cast<wchar_t*>(buf.c_str()));
}
if (helpFile != NULL)
{
buf = WideStringFromMultiByteString(helpFile);
createErrInfo->SetHelpFile(const_cast<wchar_t*>(buf.c_str()));
}
createErrInfo->SetHelpContext(helpContext);
if (createErrInfo->QueryInterface(IID_IErrorInfo, (void**)(&errInfo)) == S_OK)
{
SetErrorInfo(0, errInfo);
errInfo->Release();
}
createErrInfo->Release();
}
}
示例2: PyCom_SetCOMErrorFromExcepInfo
// Given an EXCEPINFO, register the error information with the
// IErrorInfo interface.
BOOL PyCom_SetCOMErrorFromExcepInfo(const EXCEPINFO *pexcepinfo, REFIID riid)
{
ICreateErrorInfo *pICEI;
HRESULT hr = CreateErrorInfo(&pICEI);
if ( SUCCEEDED(hr) )
{
pICEI->SetGUID(riid);
pICEI->SetHelpContext(pexcepinfo->dwHelpContext);
if ( pexcepinfo->bstrDescription )
pICEI->SetDescription(pexcepinfo->bstrDescription);
if ( pexcepinfo->bstrHelpFile )
pICEI->SetHelpFile(pexcepinfo->bstrHelpFile);
if ( pexcepinfo->bstrSource )
pICEI->SetSource(pexcepinfo->bstrSource);
IErrorInfo *pIEI;
Py_BEGIN_ALLOW_THREADS
hr = pICEI->QueryInterface(IID_IErrorInfo, (LPVOID*) &pIEI);
Py_END_ALLOW_THREADS
if ( SUCCEEDED(hr) )
{
SetErrorInfo(0, pIEI);
pIEI->Release();
}
pICEI->Release();
}
return SUCCEEDED(hr);
}
示例3: MakeHRESULT
//
//
// makes an HRESULT with a code based on the DOM error code
//
HRESULT MakeHRESULT(DOMException& ex)
{
ICreateErrorInfo* pCErr = NULL;
HRESULT sc = CreateErrorInfo(&pCErr);
if(SUCCEEDED(sc)) {
const XMLCh* msg = ex.msg;
if(msg == NULL)
{
if(ex.code >= DOMException::INDEX_SIZE_ERR &&
ex.code <= DOMException::VALIDATION_ERR)
{
sc = pCErr->SetDescription(Msgs[ex.code]);
}
else
{
sc = pCErr->SetDescription(Msgs[0]);
}
}
else
{
sc = pCErr->SetDescription(SysAllocString(ex.msg));
}
IErrorInfo* pErr = NULL;
sc = pCErr->QueryInterface(IID_IErrorInfo,(void**) &pErr);
if(SUCCEEDED(sc))
{
sc = SetErrorInfo(0,pErr);
pErr->Release();
}
pCErr->Release();
}
return 0x80040600 + ex.code;
}
示例4: GetErrorInfo
// static
void
XPCThrower::ThrowCOMError(JSContext* cx, unsigned long COMErrorCode,
nsresult rv, const EXCEPINFO * exception)
{
nsCAutoString msg;
IErrorInfo * pError;
const char * format;
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &format))
format = "";
msg = format;
#ifndef WINCE
if(exception)
{
msg += static_cast<const char *>
(_bstr_t(exception->bstrSource, false));
msg += " : ";
msg.AppendInt(static_cast<PRUint32>(COMErrorCode));
msg += " - ";
msg += static_cast<const char *>
(_bstr_t(exception->bstrDescription, false));
}
else
{
// Get the current COM error object
unsigned long result = GetErrorInfo(0, &pError);
if(SUCCEEDED(result) && pError)
{
// Build an error message from the COM error object
BSTR bstrSource = NULL;
if(SUCCEEDED(pError->GetSource(&bstrSource)) && bstrSource)
{
_bstr_t src(bstrSource, false);
msg += static_cast<const char *>(src);
msg += " : ";
}
msg.AppendInt(static_cast<PRUint32>(COMErrorCode), 16);
BSTR bstrDesc = NULL;
if(SUCCEEDED(pError->GetDescription(&bstrDesc)) && bstrDesc)
{
msg += " - ";
_bstr_t desc(bstrDesc, false);
msg += static_cast<const char *>(desc);
}
}
else
{
// No error object, so just report the result
msg += "COM Error Result = ";
msg.AppendInt(static_cast<PRUint32>(COMErrorCode), 16);
}
}
#else
// No error object, so just report the result
msg += "COM Error Result = ";
msg.AppendInt(static_cast<PRUint32>(COMErrorCode), 16);
#endif
XPCThrower::BuildAndThrowException(cx, rv, msg.get());
}
示例5: CreateErrorInfo
HRESULT
COMError::GenerateError(HM::String sDescription)
{
if (sDescription == _T(""))
{
sDescription = "The operation failed. Please check the hMailServer log for details.";
}
// Get the ICreateErrorInfo Interface
ICreateErrorInfo *pCreateErrorInfo = NULL;
HRESULT hSuccess = CreateErrorInfo(&pCreateErrorInfo);
ATLASSERT(SUCCEEDED(hSuccess));
// pCreateErrorInfo->SetGUID(CLSID_BaseApp);
pCreateErrorInfo->SetDescription(sDescription.AllocSysString());
HM::String sSource = "hMailServer COM library";
pCreateErrorInfo->SetSource(sSource.AllocSysString());
IErrorInfo *pErrInfo;
if (SUCCEEDED(pCreateErrorInfo->QueryInterface(IID_IErrorInfo,
reinterpret_cast<void**>(&pErrInfo))))
{
SetErrorInfo(0, pErrInfo);
pErrInfo->Release();
}
pCreateErrorInfo->Release();
return MAKE_HRESULT(1, FACILITY_ITF, 1001);
}
示例6: BSTRFromCStr
void VLCSupportErrorInfo::setErrorInfo(LPCOLESTR progid, REFIID riid, const char *description)
{
BSTR bstrDescription = BSTRFromCStr(CP_UTF8, description);
if( NULL != bstrDescription )
{
ICreateErrorInfo* pcerrinfo;
HRESULT hr = CreateErrorInfo(&pcerrinfo);
if( SUCCEEDED(hr) )
{
IErrorInfo* perrinfo;
pcerrinfo->SetSource((LPOLESTR)progid);
pcerrinfo->SetGUID(riid);
pcerrinfo->SetDescription((LPOLESTR)bstrDescription);
hr = pcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID*) &perrinfo);
if( SUCCEEDED(hr) )
{
::SetErrorInfo(0, perrinfo);
perrinfo->Release();
}
pcerrinfo->Release();
}
SysFreeString(bstrDescription);
}
};
示例7: GetErrorRecords
////////////////////////////////////////////////////////////////////////
// HRESULT GetErrorRecords
//
// Get the error message generated by an OLE DB object
/////////////////////////////////////////////////////////////////////////////
HRESULT GetErrorRecords(ULONG* pcRecords, IErrorRecords** ppIErrorRecords)
{
ASSERT(pcRecords && ppIErrorRecords);
HRESULT hr;
//NULL output params
*pcRecords = 0;
*ppIErrorRecords = NULL;
ISupportErrorInfo* pISupportErrorInfo = NULL;
IErrorInfo* pIErrorInfo = NULL;
//See if this interface supports ErrorInfo
//If not there is no reason to display any error
if((hr = GetErrorInfo(0, &pIErrorInfo))==S_OK && pIErrorInfo)
{
//IErrorRecords may not be supported on the existing error object.
//Some other things could have posted an error object (VB) for example...
QTESTC(hr = pIErrorInfo->QueryInterface(IID_IErrorRecords, (void**)ppIErrorRecords));
XTESTC(hr = (*ppIErrorRecords)->GetRecordCount(pcRecords));
}
CLEANUP:
SAFE_RELEASE(pISupportErrorInfo);
SAFE_RELEASE(pIErrorInfo);
return hr;
}
示例8: someText
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;
}
示例9: e
COMError::COMError(HRESULT hr)
{
_com_error e(hr);
IErrorInfo *pIErrorInfo = NULL;
GetErrorInfo(0, &pIErrorInfo);
if (pIErrorInfo == NULL)
{
e = _com_error(hr);
message = e.ErrorMessage();
}
else
{
e = _com_error(hr, pIErrorInfo);
message = e.ErrorMessage();
IErrorInfo *ptrIErrorInfo = e.ErrorInfo();
if (ptrIErrorInfo != NULL)
{
// IErrorInfo Interface located
description = (WCHAR *)e.Description();
source = (WCHAR *)e.Source();
GUID tmpGuid = e.GUID();
RPC_WSTR guidStr = NULL;
// must link in Rpcrt4.lib for UuidToString
UuidToString(&tmpGuid, &guidStr);
uuid = (WCHAR*)guidStr;
RpcStringFree(&guidStr);
ptrIErrorInfo->Release();
}
}
}
示例10:
IErrorInfo *COMException::GetErrorInfo()
{
LIMITED_METHOD_CONTRACT;
IErrorInfo *pErrorInfo = m_pErrorInfo;
if (pErrorInfo != NULL)
pErrorInfo->AddRef();
return pErrorInfo;
}
示例11: factory
/*----------------------------------------------------------------------------------------------
Static method to find a class factory (from the given CLSID) from all the class factories
that are in the linked list. If the requested class factory is not found, *ppv is set
to NULL and CLASS_E_CLASSNOTAVAILABLE is returned.
----------------------------------------------------------------------------------------------*/
HRESULT ModuleEntry::ModuleGetClassObject(REFCLSID clsid, REFIID iid, void ** ppv)
{
AssertPtrN(ppv);
if (!ppv)
return WarnHr(E_POINTER);
*ppv = NULL;
// This block of code is largely copied from the AssertNoErrorInfo method in throwable.h.
// Here, however, we don't assert, but just dump a warning to the output window and
// discard the spurious error info. This prevents asserts if Windows.Forms calls
// a class factory (as it has been known to do) with spurious error info registered.
#ifdef DEBUG
IErrorInfo * pIErrorInfo = NULL;
HRESULT hr = GetErrorInfo(0, &pIErrorInfo);
Assert(SUCCEEDED(hr));
if(pIErrorInfo != NULL) {
BSTR bstr;
hr = pIErrorInfo->GetDescription(&bstr);
Assert(SUCCEEDED(hr));
::OutputDebugString(bstr);
::SysFreeString(bstr);
hr = pIErrorInfo->GetSource(&bstr);
Assert(SUCCEEDED(hr));
::OutputDebugString(bstr);
::SysFreeString(bstr);
pIErrorInfo->Release();
}
#endif
ModuleEntry * pme;
try
{
for (pme = s_pmeFirst; pme; pme = pme->m_pobjNext)
{
AssertPtr(pme);
pme->GetClassFactory(clsid, iid, ppv);
if (*ppv)
return S_OK;
}
}
catch (const Throwable & thr)
{
return thr.Error();
}
catch (...)
{
return WarnHr(E_FAIL);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
示例12: CreateExternalException
// The CreateExternalException function uses GetErrorInfo function to get
// COM error information and then creates Exception with the error description.
ExternalException* CreateExternalException()
{
IErrorInfo* errInfo;
BSTR descriptionBStr;
std::string descriptionStr;
if (GetErrorInfo(0, &errInfo) == S_OK)
{
errInfo->GetDescription(&descriptionBStr);
descriptionStr = MultiByteStringFromWideString(descriptionBStr);
::SysFreeString(descriptionBStr);
}
return new ExternalException(descriptionStr);
}
示例13: catch
int
ErrorManager::GetNativeErrorCode(IErrorInfo *pIErrorInfo)
{
int iRetValue = 0;
HRESULT hr = S_OK;
IErrorRecords *pIErrorRecords = NULL;
ERRORINFO errorInfo = { 0 };
IErrorInfo *pIErrorInfoRecord = NULL;
try
{
hr = pIErrorInfo->QueryInterface(IID_IErrorRecords, (void **) &pIErrorRecords);
if ( FAILED(hr) || NULL == pIErrorRecords )
return -1;
pIErrorInfo->Release();
pIErrorInfo = NULL;
ULONG ulNumErrorRecs = 0;
hr = pIErrorRecords->GetRecordCount(&ulNumErrorRecs);
if ( FAILED(hr) )
return -1;
for (DWORD dwErrorIndex = 0; dwErrorIndex < ulNumErrorRecs; dwErrorIndex++)
{
hr = pIErrorRecords->GetBasicErrorInfo(dwErrorIndex, &errorInfo);
if ( FAILED(hr) )
return -1;
iRetValue = errorInfo.dwMinor;
}
}
catch( ... )
{
iRetValue = errorInfo.dwMinor;
}
if( pIErrorInfoRecord )
pIErrorInfoRecord->Release();
if ( pIErrorInfo )
pIErrorInfo->Release();
if ( pIErrorRecords )
pIErrorRecords->Release();
return iRetValue;
}
示例14:
//---------------------------------------------------------------------------
// RaiseException
//
// Raises an exception using the given source and description
//---------------------------------------------------------------------------
void
CAdRotator::RaiseException (
LPOLESTR strDescr
)
{
HRESULT hr;
ICreateErrorInfo *pICreateErr;
IErrorInfo *pIErr;
LANGID langID = LANG_NEUTRAL;
/*
* Thread-safe exception handling means that we call
* CreateErrorInfo which gives us an ICreateErrorInfo pointer
* that we then use to set the error information (basically
* to set the fields of an EXCEPINFO structure. We then
* call SetErrorInfo to attach this error to the current
* thread. ITypeInfo::Invoke will look for this when it
* returns from whatever function was invokes by calling
* GetErrorInfo.
*/
WCHAR strSource[MAX_RESSTRINGSIZE];
if ( ::LoadStringW(
_Module.GetResourceInstance(),
IDS_ERROR_SOURCE,
strSource,
MAX_RESSTRINGSIZE ) > 0 )
{
//Not much we can do if this fails.
if (!FAILED(CreateErrorInfo(&pICreateErr)))
{
pICreateErr->SetGUID(CLSID_AdRotator);
pICreateErr->SetHelpFile(L"");
pICreateErr->SetHelpContext(0L);
pICreateErr->SetSource(strSource);
pICreateErr->SetDescription(strDescr);
hr = pICreateErr->QueryInterface(IID_IErrorInfo, (void**)&pIErr);
if (SUCCEEDED(hr))
{
if(SUCCEEDED(SetErrorInfo(0L, pIErr)))
{
pIErr->Release();
}
}
}
pICreateErr->Release();
}
}
示例15: ClearErrorInfo
void JavascriptErrorDebug::ClearErrorInfo(ScriptContext* scriptContext)
{
HRESULT hr = scriptContext->GetThreadContext()->GetWinRTErrorLibrary()->RoClearError();
// If we fail to create the delay-load library or fail to find RoClearError in it, fallback to Win8 behavior.
if (FAILED(hr))
{
IErrorInfo * perrinfo;
if(NOERROR == (hr = GetErrorInfo(0L, &perrinfo)))
{
perrinfo->Release();
}
}
}