OnixS Euronext XDP Handler for C++  1.29.2.6
Error Handling
Getting Started

Error Handling Concept

Being C++ class library, the Handler uses exceptions to report about error occurred while performing certain action. For example, the Handler will raise regular exception to report about inability to find actual license for the product. However, Handler processes market data asynchronously, therefore Handler is not able to report about any further errors since market data processing is started. For this reason, the Handler exposes OnixS::Euronext::XDP::ErrorListener interface and OnixS::Euronext::XDP::Handler::registerErrorListener member to be able to subscribe to and handle errors.

Once instance of OnixS::Euronext::XDP::ErrorListener is assigned to the Handler, it will invoke OnixS::Euronext::XDP::ErrorListener::onError member each time error occurs. OnixS::Euronext::XDP::ErrorListener::onError member has several incoming parameters one of which defines human-readable explanation (description) of the error.

Example

Following sample demonstrates how to receive error notifications:

using namespace OnixS::Euronext::XDP;

class ErrorDumper : ErrorListener
{
public:
    // Assigns itself to given handler as error listener.
    ErrorDumper(Handler& handler)
    {
        handler.registerErrorListener(this);
    }

private:
    // Implements base interface to dump errors onto console.
    virtual void onError(Handler * handler, ErrorSeverity::Enum severity, ErrorCode::Enum errorCode, const char * message)
    {
        std::cout 
            << "Error while processing data on channel '" 
            << handler.realtimeServiceId() 
            << "': " 
            << enumToString(severity) << ", "
            << enumToString(errorCode) << ", "
            << message << endl;
    }
};

...

Handler handler(handlerSettings);
ErrorDumper errorDumper(&handler);

...