eSpeed Multicast Market Data Handler for C++
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::eSpeed::MarketData::ErrorListener interface and OnixS::eSpeed::MarketData::Handler::registerErrorListener member to be able to subscribe to and handle errors.

Once instance of OnixS::eSpeed::MarketData::ErrorListener is assigned to the Handler, it will invoke OnixS::eSpeed::MarketData::ErrorListener::onError member each time error occurs. OnixS::eSpeed::MarketData::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 join to multicast channel).


Following sample demonstrates how to receive error notifications:

using namespace OnixS::eSpeed::MarketData;
// ErrorListener interface can be hidden from publicity
// to make Handler 'exclusive' user of onError member.
class ErrorDumper : ErrorListener
// Assigns itself to given handler as error listener.
ErrorDumper(Handler& handler)
// Implements base interface to dump errors onto console.
virtual void onError(ErrorCode::Enum code, const std::string& description)
std::cout << "Error occured, errorCode = " << enumToString (code) << ". Description: '" << description << "'" << std::endl;
Handler handler(handlerSettings);
ErrorDumper errorDumper(handler);