void GluePrintErrorInfo(const com::ErrorInfo &info) { bool haveResultCode = false; #if defined (RT_OS_WIN) haveResultCode = info.isFullAvailable(); bool haveComponent = true; bool haveInterfaceID = true; #else /* defined (RT_OS_WIN) */ haveResultCode = true; bool haveComponent = info.isFullAvailable(); bool haveInterfaceID = info.isFullAvailable(); #endif Utf8Str str; RTCList<Utf8Str> comp; Bstr bstrDetailsText = info.getText(); if (!bstrDetailsText.isEmpty()) str = Utf8StrFmt("%ls\n", bstrDetailsText.raw()); if (haveResultCode) comp.append(Utf8StrFmt("code %Rhrc (0x%RX32)", info.getResultCode(), info.getResultCode())); if (haveComponent) comp.append(Utf8StrFmt("component %ls", info.getComponent().raw())); if (haveInterfaceID) comp.append(Utf8StrFmt("interface %ls", info.getInterfaceName().raw())); if (!info.getCalleeName().isEmpty()) comp.append(Utf8StrFmt("callee %ls", info.getCalleeName().raw())); if (comp.size() > 0) { str += "Details: "; for (size_t i = 0; i < comp.size() - 1; ++i) str += comp.at(i) + ", "; str += comp.last(); str += "\n"; } // print and log RTMsgError("%s", str.c_str()); Log(("ERROR: %s", str.c_str())); }
HRESULT VirtualBoxErrorInfo::init(const com::ErrorInfo &info, IVirtualBoxErrorInfo *aNext) { m_resultCode = info.getResultCode(); m_resultDetail = info.getResultDetail(); m_IID = info.getInterfaceID(); m_strComponent = info.getComponent(); m_strText = info.getText(); /* Recursively create VirtualBoxErrorInfo instances for the next objects. */ const com::ErrorInfo *pInfo = info.getNext(); if (pInfo) { ComObjPtr<VirtualBoxErrorInfo> nextEI; HRESULT rc = nextEI.createObject(); if (FAILED(rc)) return rc; rc = nextEI->init(*pInfo, aNext); if (FAILED(rc)) return rc; mNext = nextEI; } else mNext = aNext; return S_OK; }