#pragma once /* * Copyright Onix Solutions Limited [OnixS]. All rights reserved. * * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law * and international copyright treaties. * * Access to and use of the software is governed by the terms of the applicable OnixS Software * Services Agreement (the Agreement) and Customer end user license agreements granting * a non-assignable, non-transferable and non-exclusive license to use the software * for it's own data processing purposes under the terms defined in the Agreement. * * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part * of this source code or associated reference material to any other location for further reproduction * or redistribution, and any amendments to this copyright notice, are expressly prohibited. * * Any reproduction or redistribution for sale or hiring of the Software not in accordance with * the terms of the Agreement is a violation of copyright law. */ #include #include #include #include #include namespace OnixS { namespace FIX { /// The Engine-level exception. typedef std::exception Exception; /// The Engine-level runtime error; typedef std::runtime_error RuntimeError; /// The first received message is not a Logon (MsgType=A) FIX Message. class ONIXS_FIXENGINE_THROWABLE_API FirstMessageNotLogonException : public RuntimeError { public: /// The constructor. FirstMessageNotLogonException(const std::string & message, const Message & incomingMessage) : RuntimeError(message) , incomingMessage_(incomingMessage) {} /// The constructor. FirstMessageNotLogonException(const std::string & message, const FlatMessage & incomingMessage) : RuntimeError(message) , flatIncomingMessage_(incomingMessage) {} /// The destructor. ~FirstMessageNotLogonException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; /// Returns the received message. const Message & message() const { return incomingMessage_; } /// Returns the received message. const FlatMessage & flatMessage() const { return flatIncomingMessage_; } private: Message incomingMessage_; FlatMessage flatIncomingMessage_; }; /// The telecommunication link error is detected after sending the initial Logon message. class ONIXS_FIXENGINE_THROWABLE_API LinkErrorException : public RuntimeError { public: /// The constructor. LinkErrorException(const std::string & message) : RuntimeError(message) {} /// The destructor. ~LinkErrorException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; }; /// The first received message is a Logon message with the wrong sequence number. class ONIXS_FIXENGINE_THROWABLE_API UnexpectedSequenceNumberException : public RuntimeError { public: /// The constructor. UnexpectedSequenceNumberException(const std::string & message) : RuntimeError(message) {} /// The destructor. ~UnexpectedSequenceNumberException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; }; /// The Timeout is occurred after sending the initial Logon message. class ONIXS_FIXENGINE_THROWABLE_API TimeoutException : public RuntimeError { public: /// The constructor. TimeoutException(const std::string & message) : RuntimeError(message) {} /// The destructor. ~TimeoutException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; }; /// The first received message is an invalid Logon message. class ONIXS_FIXENGINE_THROWABLE_API ConfirmationLogonMessageErrorException : public RuntimeError { public: /// The constructor. ConfirmationLogonMessageErrorException(const std::string & message) : RuntimeError(message) {} /// The destructor. ~ConfirmationLogonMessageErrorException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; }; /// The message validation is failed. class ONIXS_FIXENGINE_THROWABLE_API ValidationException : public RuntimeError { public: /// The constructor. ValidationException(const std::string & message, Tag tag, MessageValidationFlag::Enum failedValidation) : RuntimeError(message), tag_(tag), failedValidation_(failedValidation) {} /// The destructor. ~ValidationException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; /// Returns the tag number of the invalid field. Tag tag() const { return tag_; } /// Returns the validation criteria that fails. MessageValidationFlag::Enum failedValidation() const { return failedValidation_; } private: Tag tag_; MessageValidationFlag::Enum failedValidation_; }; /// An issue is occurred during the connect process. class ONIXS_FIXENGINE_THROWABLE_API ConnectException : public RuntimeError { public: /// The constructor. ConnectException(const std::string & message, int errCode = 0) :RuntimeError(message), errCode_(errCode) {} /// The destructor. ~ConnectException() ONIXS_FIXENGINE_NOTHROW ONIXS_FIXENGINE_OVERRIDE ONIXS_FIXENGINE_DEFAULT; /// Return the system-depended error code value. int errorCode() const { return errCode_; } private: int errCode_; }; } }