Changeset 26236 in vbox
- Timestamp:
- Feb 4, 2010 2:38:16 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/SupportErrorInfo.h
r22173 r26236 246 246 */ 247 247 virtual const char *componentName() const = 0; 248 249 /**250 * Sets the error information for the current thread.251 *252 * When the error information is set, it can be retrieved by a caller of an253 * interface method using the respective methods that return an IErrorInfo254 * object in MS COM (nsIException object in XPCOM) set for the current255 * thread. This object can also be or queried for the platform-independent256 * IVirtualBoxErrorInfo interface that provides extended error information257 * (only for components from the VirtualBox COM library). Alternatively, the258 * platform-independent ErrorInfo class can be used to retrieve error info259 * in a convenient way.260 *261 * It is assumed that the interface method that uses this function returns262 * an non S_OK result code to the caller (otherwise, there is no reason263 * for the caller to check for error info after method invocation).264 *265 * Here is a table of correspondence between this method's arguments and266 * IErrorInfo/nsIException/IVirtualBoxErrorInfo attributes/methods:267 *268 * <pre>269 * argument IErrorInfo nsIException IVirtualBoxErrorInfo270 * ----------------------------------------------------------------271 * resultCode -- result resultCode272 * iid GetGUID -- interfaceID273 * component GetSource -- component274 * text GetDescription message text275 * </pre>276 *277 * Note that this is a generic method. There are more convenient overloaded278 * versions that automatically substitute some arguments taking their279 * values from the template parameters. See #setError (HRESULT, const char280 * *, ...) for an example.281 *282 * It is also possible to turn on the multi-error mode so that setting a new283 * error information does not destroy the previous error (if any) but makes284 * it accessible using the IVirtualBoxErrorInfo::next attribute. See285 * MultiResult for more information.286 *287 * @param aResultCode Result (error) code, must not be S_OK.288 * @param aIID IID of the interface that defines the error.289 * @param aComponent Name of the component that sets the error (UTF8).290 * @param aText Error message in UTF8 (must not be NULL).291 *292 * @return @a aResultCode argument, for convenience. If an error occurs293 * while setting error info itself, that error is returned instead294 * of the @a aResultCode argument.295 */296 static HRESULT setError(HRESULT aResultCode,297 const GUID &aIID,298 const char *aComponent,299 const char *aText)300 {301 return setErrorInternal(aResultCode,302 &aIID,303 aComponent,304 aText,305 false /* aWarning */);306 }307 308 static HRESULT setError(HRESULT aResultCode,309 const GUID &aIID,310 const char *aComponent,311 const Utf8Str &strText)312 {313 return setErrorInternal(aResultCode,314 &aIID,315 aComponent,316 strText,317 false /* aWarning */);318 }319 320 /**321 * Same as #setError() except that it makes sure that aResultCode doesn't322 * have the error severity bit (31) set when passed down to the created323 * IVirtualBoxErrorInfo object.324 *325 * The error severity bit is always cleared by this call, thereof you can326 * use ordinary E_XXX result code constants, for convenience. However, this327 * behavior may be non-standard on some COM platforms.328 */329 static HRESULT setWarning(HRESULT aResultCode,330 const GUID &aIID,331 const char *aComponent,332 const char *aText)333 {334 return setErrorInternal(aResultCode,335 &aIID,336 aComponent,337 aText,338 true /* aWarning */);339 }340 248 341 249 /** -
trunk/src/VBox/Main/MediumImpl.cpp
r26201 r26236 1026 1026 { 1027 1027 Assert(!m->strLastAccessError.isEmpty()); 1028 rc = setError(E_FAIL, m->strLastAccessError );1028 rc = setError(E_FAIL, m->strLastAccessError.c_str()); 1029 1029 } 1030 1030 else -
trunk/src/VBox/Main/glue/SupportErrorInfo.cpp
r26186 r26236 340 340 } 341 341 342 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const Utf8Str &strText)343 {344 HRESULT rc = setError(aResultCode,345 mainInterfaceID(),346 componentName(),347 strText);348 return rc;349 }350 351 342 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const char *aText, ...) 352 343 {
Note:
See TracChangeset
for help on using the changeset viewer.