openDAQ
Open data acquisition platform
IErrorInfo Struct Referenceabstract

Contains detailed information about error. More...

+ Inheritance diagram for IErrorInfo:
+ Collaboration diagram for IErrorInfo:

Detailed Description

Contains detailed information about error.

Most of openDAQ's methods in interfaces return ErrCode. This is just an integer number. With IErrorInfo interface it is possible to attach an error message and a source to the last error. The Interface function that returns an error can create an object that implements this interface and attaches it to thread-local storage using daqSetErrorInfo function. The Client can check the return value of an arbitrary interface function and in case of an error, it can check if IErrorInfo is stored in thread-local storage using daqGetErrorInfo for additional error information.

makeErrorInfo automatically creates IErrorInfo and calls daqSetErrorInfo. In case of an error, checkErrorInfo calls daqGetErrorInfo to get extended error information and throws an exception.

Example:

ErrCode ISomeInterface::checkValue(Int value)
{
if (value < 0)
return makeErrorInfo(OPENDAQ_ERR_INVALIDPARAMETER, "Parameter should be >= 0", nullptr);
return OPENDAQ_SUCCESS;
};
auto errCode = someInterface->checkValue(-1);
checkErrorInfo(errCode); // this will throw InvalidParameterException with above error message

Public Member Functions

virtual ErrCode INTERFACE_FUNC setMessage (IString *message)=0
 Sets the message of the error. More...
 
virtual ErrCode INTERFACE_FUNC getMessage (IString **message)=0
 Gets the message of the error. More...
 
virtual ErrCode INTERFACE_FUNC setSource (IString *source)=0
 Sets the source of the error. More...
 
virtual ErrCode INTERFACE_FUNC getSource (IString **source)=0
 Gets the source of the error. More...
 
- Public Member Functions inherited from IBaseObject
virtual ErrCode INTERFACE_FUNC borrowInterface (const IntfID &intfID, void **obj) const =0
 Returns another interface which is supported by the object without incrementing the reference count. More...
 
virtual ErrCode INTERFACE_FUNC dispose ()=0
 Disposes all references held by the object. More...
 
virtual ErrCode INTERFACE_FUNC getHashCode (SizeT *hashCode)=0
 Returns hash code of the object. More...
 
virtual ErrCode INTERFACE_FUNC equals (IBaseObject *other, Bool *equal) const =0
 Compares object to another object for equality. More...
 
virtual ErrCode INTERFACE_FUNC toString (CharPtr *str)=0
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from IUnknown
virtual ErrCode INTERFACE_FUNC queryInterface (const IntfID &intfID, void **obj)=0
 Returns another interface which is supported by the object and increments the reference count. More...
 
virtual int INTERFACE_FUNC addRef ()=0
 Increments the reference count for an interface on an object. More...
 
virtual int INTERFACE_FUNC releaseRef ()=0
 Decrements the reference count for an interface on an object. More...
 

Member Function Documentation

◆ getMessage()

virtual ErrCode INTERFACE_FUNC getMessage ( IString **  message)
pure virtual

Gets the message of the error.

Parameters
messageError description.

◆ getSource()

virtual ErrCode INTERFACE_FUNC getSource ( IString **  source)
pure virtual

Gets the source of the error.

Parameters
sourceError source.

◆ setMessage()

virtual ErrCode INTERFACE_FUNC setMessage ( IString message)
pure virtual

Sets the message of the error.

Parameters
messageError description.

◆ setSource()

virtual ErrCode INTERFACE_FUNC setSource ( IString source)
pure virtual

Sets the source of the error.

Parameters
sourceError source.
ErrCode
BEGIN_NAMESPACE_OPENDAQ typedef uint32_t ErrCode
Definition: common.h:60