Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

com::ErrorInfo Class Reference

#include <ErrorInfo.h>

Inheritance diagram for com::ErrorInfo:

com::ErrorInfoKeeper com::ProgressErrorInfo

List of all members.

Detailed Description

The ErrorInfo class provides a convenient way to retrieve error information set by the most recent interface method, that was invoked on the current thread and returned an unsuccessful result code.

Once the instance of this class is created, the error information for the current thread is cleared.

There is no sense to use instances of this class after the last invoked interface method returns a success.

The class usage pattern is as follows: IFoo *foo; ... HRESULT rc = foo->SomeMethod(); if (FAILED (rc)) { ErrorInfo info (foo); if (info.isFullAvailable()) { printf ("error message = %ls\n", info.getText().raw()); } }

This class fetches error information using the IErrorInfo interface on Win32 (MS COM) or the nsIException interface on other platforms (XPCOM), or the extended IVirtualBoxErrorInfo interface when when it is available (i.e. a given IErrorInfo or nsIException instance implements it). Currently, IVirtualBoxErrorInfo is only available for VirtualBox components.

ErrorInfo::isFullAvailable() and ErrorInfo::isBasicAvailable() determine what level of error information is available. If isBasicAvailable() returns true, it means that only IErrorInfo or nsIException is available as the source of information (depending on the platform), but not IVirtualBoxErrorInfo. If isFullAvailable() returns true, it means that all three interfaces are available. If both methods return false, no error info is available at all.

Here is a table of correspondence between this class methods and and IErrorInfo/nsIException/IVirtualBoxErrorInfo attributes/methods:

ErrorInfo IErrorInfo nsIException IVirtualBoxErrorInfo -------------------------------------------------------------------- getResultCode -- result resultCode getIID GetGUID -- interfaceID getComponent GetSource -- component getText GetDescription message text

'--' means that this interface does not provide the corresponding portion of information, therefore it is useless to query it if only isBasicAvailable() returns true. As it can be seen, the amount of information provided at the basic level, depends on the platform (MS COM or XPCOM).

Definition at line 101 of file ErrorInfo.h.

Public Member Functions

 ErrorInfo (IVirtualBoxErrorInfo *aInfo)
 ErrorInfo (const ComPtr< IVirtualBoxErrorInfo > &aPtr)
template<class I>
 ErrorInfo (const ComPtr< I > &aPtr)
template<class I>
 ErrorInfo (I *aPtr)
 ErrorInfo ()
const GuidgetCalleeIID () const
const BstrgetCalleeName () const
const BstrgetComponent () const
const GuidgetInterfaceID () const
const BstrgetInterfaceName () const
const ErrorInfogetNext () const
HRESULT getResultCode () const
const BstrgetText () const
bool isBasicAvailable () const
bool isFullAvailable () const
bool isNull () const
void setNull ()

Protected Member Functions

 ErrorInfo (bool)
void init (IVirtualBoxErrorInfo *aInfo)
void init (IUnknown *aUnk, const GUID &aIID, bool aKeepObj=false)
void init (bool aKeepObj=false)

Protected Attributes

Guid mCalleeIID
Bstr mCalleeName
Bstr mComponent
ComPtr< IUnknown > mErrorInfo
Guid mInterfaceID
Bstr mInterfaceName
bool mIsBasicAvailable: 1
bool mIsFullAvailable: 1
cppx::auto_copy_ptr< ErrorInfomNext
HRESULT mResultCode
Bstr mText

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index