OnixS CBOE CMi2 Trading Handler for C++  1.1.3.0
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, the Handler processes market data asynchronously, therefore it is not able to report about any further errors since market data processing is started. For this reason, the Handler exposes the OnixS::CBOE::Trading::CMi2::ErrorListener interface and the OnixS::CBOE::Trading::CMi2::Handler::registerErrorListener member to be able to subscribe and handle errors.

Once instance of OnixS::CBOE::Trading::CMi2::ErrorListener is assigned to the Handler, it will invoke the OnixS::CBOE::Trading::CMi2::ErrorListener::onError member each time error occurs. The OnixS::CBOE::Trading::CMi2::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:

// 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(ErrorCode::Enum code, const std::string& description)
{
std::cout << "Error occurred, errorCode = " << enumToString (code) << ". Description: '" << description << "'" << std::endl;
}
};
...
Handler handler(handlerSettings);
ErrorDumper errorDumper(handler);
...