OnixS CME Drop Copy Handler C++ library  5.7.1
API documentation
Error Handling

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::CME::DropCopy::ErrorListener interface and OnixS::CME::DropCopy::Handler::registerErrorListener member to be able to subscribe to and handle errors.

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

Usually, in case of error Handler will automatically restart market data processing starting from security definitions processing. Therefore, in most cases nothing special is to be done if further data processing is desired. However, under some circumstances, manual intrusion is required (for example, if the Handler is unable to connect).

Example

Following sample demonstrates how to receive error notifications:

using namespace OnixS::CME::DropCopy;
// ErrorListener interface can be hidden from publicity
// to make Handler 'exclusive' user of onError member.
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(const Error& error)
{
std::cout
<< "Error while processing data: "
<< error.description()
<< std::endl;
}
};
...
Handler handler(handlerSettings);
ErrorDumper errorDumper(handler);
...