Changeset 32718 in vbox for trunk/src/VBox/Main/glue
- Timestamp:
- Sep 23, 2010 12:57:52 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 66148
- Location:
- trunk/src/VBox/Main/glue
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/ErrorInfo.cpp
r30739 r32718 7 7 8 8 /* 9 * Copyright (C) 2006-20 07Oracle Corporation9 * Copyright (C) 2006-2010 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 #if !defined (VBOX_WITH_XPCOM) 21 #else 22 #include <nsIServiceManager.h> 23 #include <nsIExceptionService.h> 24 #include <nsCOMPtr.h> 20 #if defined(VBOX_WITH_XPCOM) 21 # include <nsIServiceManager.h> 22 # include <nsIExceptionService.h> 23 # include <nsCOMPtr.h> 25 24 #endif 26 25 … … 92 91 HRESULT rc = E_FAIL; 93 92 94 #if !defined 93 #if !defined(VBOX_WITH_XPCOM) 95 94 96 95 ComPtr<IErrorInfo> err; 97 rc = ::GetErrorInfo 96 rc = ::GetErrorInfo(0, err.asOutParam()); 98 97 if (rc == S_OK && err) 99 98 { … … 104 103 rc = err.queryInterfaceTo(info.asOutParam()); 105 104 if (SUCCEEDED(rc) && info) 106 init 105 init(info); 107 106 108 107 if (!mIsFullAvailable) … … 110 109 bool gotSomething = false; 111 110 112 rc = err->GetGUID 111 rc = err->GetGUID(mInterfaceID.asOutParam()); 113 112 gotSomething |= SUCCEEDED(rc); 114 113 if (SUCCEEDED(rc)) 115 GetInterfaceNameByIID 116 117 rc = err->GetSource 114 GetInterfaceNameByIID(mInterfaceID, mInterfaceName.asOutParam()); 115 116 rc = err->GetSource(mComponent.asOutParam()); 118 117 gotSomething |= SUCCEEDED(rc); 119 118 120 rc = err->GetDescription 119 rc = err->GetDescription(mText.asOutParam()); 121 120 gotSomething |= SUCCEEDED(rc); 122 121 … … 124 123 mIsBasicAvailable = true; 125 124 126 AssertMsg 125 AssertMsg(gotSomething, ("Nothing to fetch!\n")); 127 126 } 128 127 } 129 128 130 #else // defined 129 #else // defined(VBOX_WITH_XPCOM) 131 130 132 131 nsCOMPtr<nsIExceptionService> es; … … 135 134 { 136 135 nsCOMPtr<nsIExceptionManager> em; 137 rc = es->GetCurrentExceptionManager(getter_AddRefs 136 rc = es->GetCurrentExceptionManager(getter_AddRefs(em)); 138 137 if (NS_SUCCEEDED(rc)) 139 138 { … … 148 147 rc = ex.queryInterfaceTo(info.asOutParam()); 149 148 if (NS_SUCCEEDED(rc) && info) 150 init 149 init(info); 151 150 152 151 if (!mIsFullAvailable) … … 163 162 { 164 163 mText = Bstr(pszMsg); 165 nsMemory::Free( mText);164 nsMemory::Free(pszMsg); 166 165 } 167 166 … … 169 168 mIsBasicAvailable = true; 170 169 171 AssertMsg 170 AssertMsg(gotSomething, ("Nothing to fetch!\n")); 172 171 } 173 172 174 173 // set the exception to NULL (to emulate Win32 behavior) 175 em->SetCurrentException 174 em->SetCurrentException(NULL); 176 175 177 176 rc = NS_OK; … … 183 182 rc = NS_OK; 184 183 185 AssertComRC 186 187 #endif // defined 184 AssertComRC(rc); 185 186 #endif // defined(VBOX_WITH_XPCOM) 188 187 } 189 188 … … 196 195 return; 197 196 198 #if !defined 197 #if !defined(VBOX_WITH_XPCOM) 199 198 200 199 ComPtr<IUnknown> iface = aI; … … 203 202 if (SUCCEEDED(rc)) 204 203 { 205 rc = serr->InterfaceSupportsErrorInfo 204 rc = serr->InterfaceSupportsErrorInfo(aIID); 206 205 if (SUCCEEDED(rc)) 207 init 206 init(aKeepObj); 208 207 } 209 208 210 209 #else 211 210 212 init 211 init(aKeepObj); 213 212 214 213 #endif … … 217 216 { 218 217 mCalleeIID = aIID; 219 GetInterfaceNameByIID 218 GetInterfaceNameByIID(aIID, mCalleeName.asOutParam()); 220 219 } 221 220 } … … 223 222 void ErrorInfo::init(IVirtualBoxErrorInfo *info) 224 223 { 225 AssertReturnVoid 224 AssertReturnVoid(info); 226 225 227 226 HRESULT rc = E_FAIL; … … 230 229 LONG lrc; 231 230 232 rc = info->COMGETTER(ResultCode) 231 rc = info->COMGETTER(ResultCode)(&lrc); mResultCode = lrc; 233 232 gotSomething |= SUCCEEDED(rc); 234 233 gotAll &= SUCCEEDED(rc); 235 234 236 235 Bstr iid; 237 rc = info->COMGETTER(InterfaceID) 236 rc = info->COMGETTER(InterfaceID)(iid.asOutParam()); 238 237 gotSomething |= SUCCEEDED(rc); 239 238 gotAll &= SUCCEEDED(rc); … … 241 240 { 242 241 mInterfaceID = iid; 243 GetInterfaceNameByIID 244 } 245 246 rc = info->COMGETTER(Component) 247 gotSomething |= SUCCEEDED(rc); 248 gotAll &= SUCCEEDED(rc); 249 250 rc = info->COMGETTER(Text) 242 GetInterfaceNameByIID(mInterfaceID, mInterfaceName.asOutParam()); 243 } 244 245 rc = info->COMGETTER(Component)(mComponent.asOutParam()); 246 gotSomething |= SUCCEEDED(rc); 247 gotAll &= SUCCEEDED(rc); 248 249 rc = info->COMGETTER(Text)(mText.asOutParam()); 251 250 gotSomething |= SUCCEEDED(rc); 252 251 gotAll &= SUCCEEDED(rc); … … 255 254 256 255 ComPtr<IVirtualBoxErrorInfo> next; 257 rc = info->COMGETTER(Next) 256 rc = info->COMGETTER(Next)(next.asOutParam()); 258 257 if (SUCCEEDED(rc) && !next.isNull()) 259 258 { … … 270 269 mIsFullAvailable = gotAll; 271 270 272 AssertMsg 271 AssertMsg(gotSomething, ("Nothing to fetch!\n")); 273 272 } 274 273 … … 279 278 //////////////////////////////////////////////////////////////////////////////// 280 279 281 ProgressErrorInfo::ProgressErrorInfo 282 ErrorInfo 280 ProgressErrorInfo::ProgressErrorInfo(IProgress *progress) : 281 ErrorInfo(false /* aDummy */) 283 282 { 284 283 Assert(progress); … … 287 286 288 287 ComPtr<IVirtualBoxErrorInfo> info; 289 HRESULT rc = progress->COMGETTER(ErrorInfo) 288 HRESULT rc = progress->COMGETTER(ErrorInfo)(info.asOutParam()); 290 289 if (SUCCEEDED(rc) && info) 291 init 290 init(info); 292 291 } 293 292 … … 305 304 HRESULT rc = S_OK; 306 305 307 #if !defined 306 #if !defined(VBOX_WITH_XPCOM) 308 307 309 308 ComPtr<IErrorInfo> err; … … 311 310 { 312 311 rc = mErrorInfo.queryInterfaceTo(err.asOutParam()); 313 AssertComRC 314 } 315 rc = ::SetErrorInfo 316 317 #else // !defined 312 AssertComRC(rc); 313 } 314 rc = ::SetErrorInfo(0, err); 315 316 #else // !defined(VBOX_WITH_XPCOM) 318 317 319 318 nsCOMPtr <nsIExceptionService> es; 320 es = do_GetService 319 es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc); 321 320 if (NS_SUCCEEDED(rc)) 322 321 { 323 322 nsCOMPtr <nsIExceptionManager> em; 324 rc = es->GetCurrentExceptionManager (getter_AddRefs(em));323 rc = es->GetCurrentExceptionManager(getter_AddRefs(em)); 325 324 if (NS_SUCCEEDED(rc)) 326 325 { … … 329 328 { 330 329 rc = mErrorInfo.queryInterfaceTo(ex.asOutParam()); 331 AssertComRC 330 AssertComRC(rc); 332 331 } 333 rc = em->SetCurrentException 332 rc = em->SetCurrentException(ex); 334 333 } 335 334 } 336 335 337 #endif // !defined 336 #endif // !defined(VBOX_WITH_XPCOM) 338 337 339 338 if (SUCCEEDED(rc)) -
trunk/src/VBox/Main/glue/errorprint.cpp
r30764 r32718 7 7 8 8 /* 9 * Copyright (C) 2009 Oracle Corporation9 * Copyright (C) 2009-2010 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 25 25 #include <iprt/stream.h> 26 #include <iprt/message.h> 26 27 #include <iprt/path.h> 27 28 … … 31 32 void GluePrintErrorInfo(com::ErrorInfo &info) 32 33 { 33 Utf8Str str = Utf8StrFmt(" ERROR:%ls\n"34 Utf8Str str = Utf8StrFmt("%ls\n" 34 35 "Details: code %Rhrc (0x%RX32), component %ls, interface %ls, callee %ls\n" 35 36 , … … 41 42 info.getCalleeName().raw()); 42 43 // print and log 43 RT Printf("%s", str.c_str());44 Log((" %s", str.c_str()));44 RTMsgError("%s", str.c_str()); 45 Log(("ERROR: %s", str.c_str())); 45 46 } 46 47 … … 55 56 strFilename.c_str()); 56 57 // print and log 57 RT Printf("%s", str.c_str());58 RTStrmPrintf(g_pStdErr, "%s", str.c_str()); 58 59 Log(("%s", str.c_str())); 59 60 } … … 61 62 void GluePrintRCMessage(HRESULT rc) 62 63 { 63 Utf8Str str = Utf8StrFmt(" ERROR: code %Rhra (extended info not available)\n", rc);64 Utf8Str str = Utf8StrFmt("Code %Rhra (extended info not available)\n", rc); 64 65 // print and log 65 RT Printf("%s", str.c_str());66 Log((" %s", str.c_str()));66 RTMsgError("%s", str.c_str()); 67 Log(("ERROR: %s", str.c_str())); 67 68 } 68 69
Note:
See TracChangeset
for help on using the changeset viewer.