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.

DAQ_MAKE_ERROR_INFO 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 DAQ_MAKE_ERROR_INFO(OPENDAQ_ERR_INVALIDPARAMETER, "Parameter should be >= 0");
return OPENDAQ_SUCCESS;
};
auto errCode = someInterface->checkValue(-1);
checkErrorInfo(errCode); // this will throw InvalidParameterException with above error message
BEGIN_NAMESPACE_OPENDAQ typedef uint32_t ErrCode
Definition: common.h:60

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...
 
virtual ErrCode INTERFACE_FUNC setFileName (ConstCharPtr fileName)=0
 Sets the file name where the error occurred. More...
 
virtual ErrCode INTERFACE_FUNC getFileName (ConstCharPtr *fileName)=0
 Gets the file name where the error occurred. More...
 
virtual ErrCode INTERFACE_FUNC setFileLine (Int fileLine)=0
 Sets the line number in the file where the error occurred. More...
 
virtual ErrCode INTERFACE_FUNC getFileLine (Int *fileLine)=0
 Gets the line number in the file where the error occurred. 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

◆ getFileLine()

virtual ErrCode INTERFACE_FUNC getFileLine ( Int *  fileLine)
pure virtual

Gets the line number in the file where the error occurred.

Parameters
fileLineLine number.

◆ getFileName()

virtual ErrCode INTERFACE_FUNC getFileName ( ConstCharPtr *  fileName)
pure virtual

Gets the file name where the error occurred.

Parameters
fileNameFile name.

◆ 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.

◆ setFileLine()

virtual ErrCode INTERFACE_FUNC setFileLine ( Int  fileLine)
pure virtual

Sets the line number in the file where the error occurred.

Parameters
fileLineLine number.

◆ setFileName()

virtual ErrCode INTERFACE_FUNC setFileName ( ConstCharPtr  fileName)
pure virtual

Sets the file name where the error occurred.

Parameters
fileNameFile name.

◆ 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.