dca_interface  6.3.4
DCA Error Handling

Introduction

Collection of classes used for error handling and return codes.

There (at least) two different types of function prototypes.
One that returns a FunctionResult and one that returns an instance of a DCA object.
Functions that return a FunctionResult do not throw an exception.
FunctionResult fr = function1();
The FunctionResult::operator bool() can be used to determine whether an error has occured.
Functions that return an instance to a DCA object throw an exception on error.
AnyInstance = function2();
The details of the error can be examined by using the ExDca::getReturnCode() function
Use a dca::ExDca try-catch handler for all methods that do not return a FunctionResult.
Ensure that you have defined (at least) an dca::ExDca catch handler at the highest level of your application.
See also
DCA Generic Error Codes

Error Handling Sample

void main()
{
try {
// required 3rd party library startups
// may throw an ExDca
// call a function that returns a FunctionResult...
dca::FunctionResult myFR = aDcaClass.doSomething();
if( !myFR ) {
// error occurred! -> log error and abort
cout << "DCA error return code received; Error code: " << myFR.getReturnCode()
<< ", Description: " << myFR.getDescription() << endl;
}
}
catch( const dca::ExDca& ex ) {
cout << "DCA error occurred; Error code: " << ex.getReturnCode()
<< ", Description: " << ex.getDescription()
<< ". Aborting" << endl;
}
// required 3rd party library shutdowns
}

Classes

class  dca::FunctionResult
 Standard function result. More...
 
class  dca::ExDca
 Exception class used in the DCA. More...
 
Exception class used in the DCA.
Definition: base_classes.h:237
void InitCUrl()
Initializes libcurl. Do not use any DCA function before initializing libcurl.
std::string getDescription() const
Returns a description of the error.
DCA_RESULT_TYPE getReturnCode() const
Returns the last error code (if any).
void SetOpenSslCallbacks()
Initializes the required callbacks for OpenSSL when using HTTPS or SSL connections in a multi-threade...
void UnsetOpenSslCallbacks()
Unsets the openssl callbacks. Do not call any DCA function after you have called this function.
void DeinitCUrl()
Deinitializes libcurl. Do not call any DCA function after you have called this function.
DCA_RESULT_TYPE getReturnCode() const
Gets the code of the error.
Encapsulates the init and deinit of the DCA API.
Definition: base_classes.h:315
std::string getDescription() const
Returns the description for the error or warning.
Standard function result.
Definition: base_classes.h:148
static DcaInstance create(const InitData &initData)
Creates a DcaInstance, starts up the DCA API and initializes the required main module.
int main(int argc, char *argv[])
The main routine.