//////////////////////////////////////////////////////////////////////// // 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; }
// 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()); }
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(); } } }
//////////////////////////////////////////////////////////////////////// // // Client Side Errors - translate a COM failure to a Python exception // //////////////////////////////////////////////////////////////////////// PyObject *PyCom_BuildPyException(HRESULT errorhr, IUnknown *pUnk /* = NULL */, REFIID iid /* = IID_NULL */) { PyObject *obEI = NULL; TCHAR scodeStringBuf[512]; GetScodeString(errorhr, scodeStringBuf, sizeof(scodeStringBuf)/sizeof(scodeStringBuf[0])); #ifndef MS_WINCE // WINCE doesnt appear to have GetErrorInfo() - compiled, but doesnt link! if (pUnk != NULL) { assert(iid != IID_NULL); // If you pass an IUnknown, you should pass the specific IID. // See if it supports error info. ISupportErrorInfo *pSEI; HRESULT hr; Py_BEGIN_ALLOW_THREADS hr = pUnk->QueryInterface(IID_ISupportErrorInfo, (void **)&pSEI); if (SUCCEEDED(hr)) { hr = pSEI->InterfaceSupportsErrorInfo(iid); pSEI->Release(); // Finished with this object } Py_END_ALLOW_THREADS if (SUCCEEDED(hr)) { IErrorInfo *pEI; Py_BEGIN_ALLOW_THREADS hr=GetErrorInfo(0, &pEI); Py_END_ALLOW_THREADS if (hr==S_OK) { obEI = PyCom_PyObjectFromIErrorInfo(pEI, errorhr); PYCOM_RELEASE(pEI); } } }
HRESULT CMsgContainerCAN::GetMessageName(STCANDATA& sCANMsg, CString& msgName, bool formatHexForId) { if (IS_ERR_MESSAGE(sCANMsg.m_ucDataType)) { GetErrorInfo(sCANMsg, msgName); } else { //Message Name std::string strName = ""; IFrame* pouFrame = nullptr; ERRORCODE eResult = mBmNetwork->GetFrame(CAN, 0, sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID, nullptr, &pouFrame); if (EC_SUCCESS == eResult && nullptr != pouFrame) { pouFrame->GetName(strName); msgName = strName.c_str(); } else { if (formatHexForId == true) { msgName.Format("0x%X", sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID); } else { msgName.Format("%d", sCANMsg.m_uDataInfo.m_sCANMsg.m_unMsgID); } } } return S_OK; }
void PrintError(const char* pFilename, const char* pErrorString) { int lineNumber = 1; int column = 1; int offsetToStartOfLine = -1; int offsetToEndOfLine = -1; int offendingItemStart = 0; int offendingItemEnd = 0; GetErrorInfo(lineNumber, column, offsetToStartOfLine, offsetToEndOfLine, offendingItemStart, offendingItemEnd); printf("%s(%d:%d) : error : %s\n", pFilename, lineNumber, column, pErrorString); char errorItem[512]; char errorLine[512]; if ( offendingItemStart == offendingItemEnd && s_pCompilerData->source[offendingItemStart] == 0 ) { strcpy(errorLine, "End Of File"); strcpy(errorItem, "N/A"); } else { strncpy(errorLine, &s_pCompilerData->source[offsetToStartOfLine], offsetToEndOfLine - offsetToStartOfLine); errorLine[offsetToEndOfLine - offsetToStartOfLine] = 0; strncpy(errorItem, &s_pCompilerData->source[offendingItemStart], offendingItemEnd - offendingItemStart); errorItem[offendingItemEnd - offendingItemStart] = 0; } printf("Line:\n%s\nOffending Item: %s\n", errorLine, errorItem); }
JNIEXPORT jlong JNICALL Java_com4j_Native_getErrorInfo( JNIEnv* env, jclass __unused__, jlong pComObject, jlong iid1, jlong iid2) { MyGUID iid(iid1,iid2); try { ISupportErrorInfoPtr p(reinterpret_cast<IUnknown*>(pComObject)); if(p==NULL) return 0; // not supported HRESULT hr = p->InterfaceSupportsErrorInfo(iid); if(FAILED(hr)) { error(env,__FILE__,__LINE__,hr,"ISupportErrorInfo::InterfaceSupportsErrorInfo failed"); return 0; } if(hr!=S_OK) return 0; // not supported IErrorInfo* pError; hr = GetErrorInfo(0,&pError); if(FAILED(hr)) { error(env,__FILE__,__LINE__,hr,"GetErrorInfo failed"); return 0; } // return the pointer return reinterpret_cast<jlong>(pError); } catch (...) { // an exception occured. This might happen, if the automation server is not available due to a crash. return 0; } return 0; }
HRESULT __RPC_STUB IDBInitialize_Initialize_Stub(IDBInitialize* This, IErrorInfo **ppErrorInfoRem) { HRESULT hr; TRACE("(%p, %p)\n", This, ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = IDBInitialize_Initialize(This); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); return hr; }
HRESULT __RPC_STUB IDBDataSourceAdmin_DestroyDataSource_Stub(IDBDataSourceAdmin* This, IErrorInfo **error) { HRESULT hr; TRACE("(%p, %p)\n", This, error); *error = NULL; hr = IDBDataSourceAdmin_DestroyDataSource(This); if(FAILED(hr)) GetErrorInfo(0, error); return hr; }
HRESULT __RPC_STUB IDBInitialize_Uninitialize_Stub(IDBInitialize* This, IErrorInfo **error) { HRESULT hr; TRACE("(%p, %p)\n", This, error); *error = NULL; hr = IDBInitialize_Uninitialize(This); if(FAILED(hr)) GetErrorInfo(0, error); return hr; }
HRESULT MMSQLError::ReportErrors(HRESULT err, TCHAR *errStr, size_t len) { HRESULT hr; char *errStr_c=new char[len]; errStr_c[0]='\0'; // Obtain the current Error object, if any, by using the // OLE Automation GetErrorInfo function, which will give // us back an IErrorInfo interface pointer if successful hr = GetErrorInfo(0, &pIErrorInfo); // We've got the IErrorInfo interface pointer on the Error object if( SUCCEEDED(hr) && pIErrorInfo ) { // OLE DB extends the OLE Automation error model by allowing // Error objects to support the IErrorRecords interface; this // interface can expose information on multiple errors. hr = pIErrorInfo->QueryInterface(IID_IErrorRecords, (void**)&pIErrorRecords); if(SUCCEEDED(hr)) { // Get the count of error records from the object hr = pIErrorRecords->GetRecordCount(&cRecords); // Loop through the set of error records and // display the error information for each one for( iErr = 0; iErr < cRecords; iErr++ ) { char curErr[1024]; MMSQLErrorRecord theErr(err,iErr,pIErrorRecords); ReportError(&theErr,curErr,1024); if(iErr>0) sprintf_s(errStr_c,len,"%s|",errStr_c); sprintf_s(errStr_c,len,"%s%s",errStr_c,curErr); } } // The object didn't support IErrorRecords; display // the error information for this single error else { MMSQLErrorRecord theErr(err,pIErrorInfo); ReportError(&theErr,errStr_c,len); } } // There was no Error object, so just display the HRESULT to the user else { MMSQLErrorRecord theErr(err,NULL); ReportError(&theErr,errStr_c,len); } _bstr_t dummy=errStr_c; _stprintf_s(errStr,len,TEXT("%s"),(TCHAR *)dummy); delete errStr_c; return hr; } //ReportErrors
/*---------------------------------------------------------------------------------------------- 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; }
HRESULT __RPC_STUB IDBDataSourceAdmin_ModifyDataSource_Stub(IDBDataSourceAdmin* This, ULONG cPropertySets, DBPROPSET *rgPropertySets, IErrorInfo **error) { HRESULT hr; TRACE("(%p, %d, %p, %p)\n", This, cPropertySets, rgPropertySets, error); *error = NULL; hr = IDBDataSourceAdmin_ModifyDataSource(This, cPropertySets, rgPropertySets); if(FAILED(hr)) GetErrorInfo(0, error); return hr; }
HRESULT MMSQLError::ReportErrors(HRESULT err, TCHAR *msg, FILE *stream) { HRESULT hr; _bstr_t dummy; // Obtain the current Error object, if any, by using the // OLE Automation GetErrorInfo function, which will give // us back an IErrorInfo interface pointer if successful severity=msg[10]; hr = GetErrorInfo(0, &pIErrorInfo); // We've got the IErrorInfo interface pointer on the Error object if( SUCCEEDED(hr) && pIErrorInfo ) { // OLE DB extends the OLE Automation error model by allowing // Error objects to support the IErrorRecords interface; this // interface can expose information on multiple errors. hr = pIErrorInfo->QueryInterface(IID_IErrorRecords, (void**)&pIErrorRecords); if(SUCCEEDED(hr)) { // Get the count of error records from the object hr = pIErrorRecords->GetRecordCount(&cRecords); // Loop through the set of error records and // display the error information for each one for( iErr = 0; iErr < cRecords; iErr++ ) { MMSQLErrorRecord theErr(err,iErr,pIErrorRecords); dummy=msg; ReportError(&theErr,(char *)dummy,stream); // myDisplayErrorRecord(originalError, iErr, pIErrorRecords, // pwszFile, ulLine); } } // The object didn't support IErrorRecords; display // the error information for this single error else { // myDisplayErrorInfo(hrReturned, pIErrorInfo, pwszFile, ulLine); MMSQLErrorRecord theErr(err,pIErrorInfo); dummy=msg; ReportError(&theErr,(char *)dummy,stream); } } // There was no Error object, so just display the HRESULT to the user else { MMSQLErrorRecord theErr(err,NULL); dummy=msg; ReportError(&theErr,(char *)dummy,stream); } return hr; } //ReportErrors
HRESULT __RPC_STUB IDBCreateSession_CreateSession_Stub(IDBCreateSession* This, IUnknown *pUnkOuter, REFIID riid, IUnknown **ppDBSession, IErrorInfo **ppErrorInfoRem) { HRESULT hr; TRACE("(%p, %p, %s, %p, %p)\n", This, pUnkOuter, debugstr_guid(riid), ppDBSession, ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = IDBCreateSession_CreateSession(This, pUnkOuter, riid, ppDBSession); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); return hr; }
// 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); }
HRESULT __RPC_STUB IAccessor_ReleaseAccessor_Stub(IAccessor* This, HACCESSOR hAccessor, DBREFCOUNT *pcRefCount, IErrorInfo **ppErrorInfoRem) { HRESULT hr; TRACE("(%p)->(%lx, %p, %p)\n", This, hAccessor, pcRefCount, ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = IAccessor_ReleaseAccessor(This, hAccessor, pcRefCount); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); return hr; }
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(); } } }
HRESULT __RPC_STUB ICommandText_SetCommandText_Stub(ICommandText* This, REFGUID rguidDialect, LPCOLESTR pwszCommand, IErrorInfo **ppErrorInfoRem) { HRESULT hr; TRACE("(%p)->(%s, %s, %p)\n", This, debugstr_guid(rguidDialect), debugstr_w(pwszCommand), ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = ICommandText_SetCommandText(This, rguidDialect, pwszCommand); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); return hr; }
HRESULT __RPC_STUB IRowsetInfo_GetProperties_Stub(IRowsetInfo* This, ULONG cPropertyIDSets, const DBPROPIDSET *rgPropertyIDSets, ULONG *pcPropertySets, DBPROPSET **prgPropertySets, IErrorInfo **ppErrorInfoRem) { HRESULT hr; TRACE("(%p)->(%d, %p, %p, %p, %p)\n", This, cPropertyIDSets, rgPropertyIDSets, pcPropertySets, prgPropertySets, ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = IRowsetInfo_GetProperties(This, cPropertyIDSets, rgPropertyIDSets, pcPropertySets, prgPropertySets); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); TRACE("returning %08x\n", hr); return hr; }
void WINAPI _com_issue_errorex(HRESULT hr, IUnknown *punk, REFIID riid) { void *pv; IErrorInfo *perrinfo = NULL; if (SUCCEEDED(punk->QueryInterface(riid, &pv))) { ISupportErrorInfo *pserrinfo = static_cast<ISupportErrorInfo *>(pv); if (pserrinfo->InterfaceSupportsErrorInfo(riid) == S_OK) (void)GetErrorInfo(0, &perrinfo); pserrinfo->Release(); } com_error_handler(hr, perrinfo); }
HRESULT __RPC_STUB IAccessor_CreateAccessor_Stub(IAccessor* This, DBACCESSORFLAGS dwAccessorFlags, DBCOUNTITEM cBindings, DBBINDING *rgBindings, DBLENGTH cbRowSize, HACCESSOR *phAccessor, DBBINDSTATUS *rgStatus, IErrorInfo **ppErrorInfoRem) { HRESULT hr; TRACE("(%p)->(%08x, %d, %p, %d, %p, %p, %p)\n", This, dwAccessorFlags, cBindings, rgBindings, cbRowSize, phAccessor, rgStatus, ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = IAccessor_CreateAccessor(This, dwAccessorFlags, cBindings, rgBindings, cbRowSize, phAccessor, rgStatus); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); return hr; }
void CPigEngine::LoadScriptFile(CPigBehaviorScriptType* pScript, const WIN32_FIND_DATA* pffd, tstring strFileName) { // Initialize the specified object HRESULT hr = pScript->Load(pffd, strFileName); if (SUCCEEDED(hr) && SUCCEEDED(hr = AddInvokeCommands(pScript))) return; // Display the error information IErrorInfo* pei; HRESULT hrEI = GetErrorInfo(0, &pei); _com_error err(hr, pei); _bstr_t bstrDesc(err.Description()); _TRACE2("CPigEngine::LoadScriptFile(%s): %s\n", strFileName.c_str(), (bstrDesc.length()) ? LPCTSTR(bstrDesc) : err.ErrorMessage()); }
bool CGlfwProxy::Init() { char pth[256]; ::GetCurrentDirectoryA( 250 , pth ); std::ifstream strm("cfg/gui.lua", std::ios::in | std::ios::binary); DWORD err= GetLastError(); IErrorInfo *ei; GetErrorInfo(err, &ei); std::stringstream buf; buf << strm.rdbuf(); std::string contents(buf.str()); CFLua::CLuaProxy::Ins().DoString(contents.c_str()); return true; }
HRESULT __RPC_STUB IDBDataSourceAdmin_GetCreationProperties_Stub(IDBDataSourceAdmin* This, ULONG cPropertyIDSets, const DBPROPIDSET *rgPropertyIDSets, ULONG *pcPropertyInfoSets, DBPROPINFOSET **prgPropertyInfoSets, DBCOUNTITEM *pcOffsets, DBBYTEOFFSET **prgDescOffsets, ULONG *pcbDescBuffer, OLECHAR **ppDescBuffer, IErrorInfo **error) { HRESULT hr; TRACE("(%p, %d, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, cPropertyIDSets, rgPropertyIDSets, pcPropertyInfoSets, prgPropertyInfoSets, pcOffsets, prgDescOffsets, pcbDescBuffer, ppDescBuffer, error); *error = NULL; hr = IDBDataSourceAdmin_GetCreationProperties(This, cPropertyIDSets, rgPropertyIDSets, pcPropertyInfoSets, prgPropertyInfoSets, ppDescBuffer); if(FAILED(hr)) GetErrorInfo(0, error); return hr; }
static std::string get() { // USES_CONVERSION; CComPtr<IErrorInfo> errorInfo; HRESULT hr = GetErrorInfo(NULL, &errorInfo); if (FAILED(hr) || hr == S_FALSE) return "unknown error: " + error::format::from_system(hr); CComBSTR bDesc, bSource; hr = errorInfo->GetSource(&bSource); if (FAILED(hr)) return "unknown error: " + error::format::from_system(hr); hr = errorInfo->GetDescription(&bDesc); if (FAILED(hr)) return "unknown error: " + error::format::from_system(hr); std::string ret = utf8::cvt<std::string>(OLE2T(bSource)); ret += " - "; ret += utf8::cvt<std::string>(OLE2T(bDesc)); return ret; }
HRESULT __RPC_STUB ISessionProperties_SetProperties_Stub(ISessionProperties* This, ULONG cPropertySets, DBPROPSET *rgPropertySets, ULONG cTotalProps, DBPROPSTATUS *rgPropStatus, IErrorInfo **ppErrorInfoRem) { ULONG prop_set, prop, total_props = 0; HRESULT hr; TRACE("(%p, %d, %p, %d, %p, %p)\n", This, cPropertySets, rgPropertySets, cTotalProps, rgPropStatus, ppErrorInfoRem); *ppErrorInfoRem = NULL; hr = ISessionProperties_SetProperties(This, cPropertySets, rgPropertySets); if(FAILED(hr)) GetErrorInfo(0, ppErrorInfoRem); for(prop_set = 0; prop_set < cPropertySets; prop_set++) for(prop = 0; prop < rgPropertySets[prop_set].cProperties; prop++) rgPropStatus[total_props++] = rgPropertySets[prop_set].rgProperties[prop].dwStatus; return hr; }
HRESULT RaiseError(ERRORINFO &info, CComVariant &var, BSTR bstrSQLState) { CComPtr<IErrorInfo> spErrorInfo; GetErrorInfo(0, &spErrorInfo); // 에러 객체가 없으면 생성한다. // 에러 객체는 MDAC SDK가 제공한다. if(spErrorInfo==NULL) spErrorInfo.CoCreateInstance(CLSID_EXTENDEDERRORINFO, NULL, CLSCTX_INPROC_SERVER); // 추가할 에러 DISPPARAMS dispparams = { NULL, NULL, 0, 0 }; if(V_VT(&var)!=VT_EMPTY) { dispparams.rgvarg = &var; dispparams.cArgs = 1; } CComPtr<IUnknown> spSQLInfo; if(bstrSQLState) { CComPolyObject<CCUBRIDErrorInfo> *pObj; CComPolyObject<CCUBRIDErrorInfo>::CreateInstance(NULL, &pObj); CCUBRIDErrorInfo *pSQLInfo = &(pObj->m_contained); pSQLInfo->m_bstrSQLState = bstrSQLState; pSQLInfo->m_lNativeError = info.dwMinor; pSQLInfo->QueryInterface(__uuidof(IUnknown), (void **)&spSQLInfo); } // IErrorRecords의 포인터를 구해서 에러를 추가한다. CComPtr<IErrorRecords> spErrorRecords; spErrorInfo->QueryInterface(__uuidof(IErrorRecords), (void **)&spErrorRecords); spErrorRecords->AddErrorRecord(&info, info.dwMinor, &dispparams, spSQLInfo, 0); // 에러 객체 등록 SetErrorInfo(0, spErrorInfo); return info.hrError; }
int ProcessErrorInfo(int new_sock) { ERRORINFO_T ErrorInfo[MAX_RETURN_NUM]; PRODUCTID_T ProductID; int ErrorCount = 0; int ErrorCode = 0; memset(ErrorInfo, 0, sizeof(ERRORINFO_T) * MAX_RETURN_NUM); if((ErrorCode = ReadProductID(&ProductID, new_sock)) != NO_ERROR) { printLog(HEAD, "ERR: read error! ErroCode(%d)\n", ErrorCode) ; return ErrorCode; } ErrorCode = GetErrorInfo(ProductID, &ErrorCount, ErrorInfo) ; printLog(HEAD, "work_errorInfo_get(): ret(%d) count(%d)\n", ErrorCode, ErrorCount) ; ErrorCode = WriteErrorInfo(ErrorInfo, ErrorCode, ErrorCount, new_sock); return ErrorCode; }
CUniString vboxFormatError(HRESULT hr) { // Get error info Simple::CAutoPtr<IErrorInfo, SRefCounted> spErrorInfo; GetErrorInfo(0, &spErrorInfo); CUniString str; if (spErrorInfo) { BSTR bstr=NULL; spErrorInfo->GetDescription(&bstr); str=bstr; SysFreeString(bstr); } else { str=FormatError(hr); } return str; }