OnixS C++ CME MDP Conflated TCP Handler  1.3.1
API Documentation
SessionException.h
Go to the documentation of this file.
1 /*
2  * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3  *
4  * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5  * and international copyright treaties.
6  *
7  * Access to and use of the software is governed by the terms of the applicable OnixS Software
8  * Services Agreement (the Agreement) and Customer end user license agreements granting
9  * a non-assignable, non-transferable and non-exclusive license to use the software
10  * for it's own data processing purposes under the terms defined in the Agreement.
11  *
12  * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13  * of this source code or associated reference material to any other location for further reproduction
14  * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15  *
16  * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17  * the terms of the Agreement is a violation of copyright law.
18  */
19 
20 #pragma once
21 
24 
25 #include <string>
26 
27 #if WIN32
28 #pragma warning(push)
29 #pragma warning(disable : 4275)
30 #pragma warning(disable : 4251)
31 #endif
32 
33 namespace OnixS {
34 namespace CME {
35 namespace ConflatedTCP {
36 namespace Exceptions{
37 
38 /**
39  * A Session-related exception.
40  */
41 class ONIXS_CONFLATEDTCP_EXPORTED SessionException : public std::exception
42 {
43 public:
44  SessionException(SessionErrorReason::Enum reason, const std::string& message);
45 
46  SessionException(SessionErrorReason::Enum reason, const std::string& message, const std::exception& cause);
47 
49 
51 
53  {
54  return reason_;
55  }
56 
57  const std::string& toString() const
58  {
59  return message_;
60  }
61 
62 private:
63  std::string message_;
65 };
66 
67 /**
68  * An unexpected message type is received.
69  */
71  : public SessionException
72 {
73 public:
74  UnexpectedMessageTypeException(const std::string& rejectReason, Messaging::SbeMessage incomingMessage);
75 
77 
78  Messaging::SbeMessage receivedMessage() const;
79 
80 private:
81  std::vector<unsigned char> buffer_;
82 };
83 
84 /**
85  * A telecommunication link error is detected.
86  */
88  : public SessionException
89 {
90 public:
91  explicit LinkErrorException(const std::string& rejectReason);
92 
94 };
95 
96 /**
97  * An unexpected message sequence number is detected.
98  */
100  : public SessionException
101 {
102 public:
103  UnexpectedSequenceNumberException(Messaging::SbeMessage receivedMessage, const std::string& rejectReason,
104  SeqNumber actualSeqNum, SeqNumber expectedSeqNum);
105 
107 
109  {
110  return actualSeqNum_;
111  }
112 
114  {
115  return expectedSeqNum_;
116  }
117 
118  Messaging::SbeMessage receivedMessage() const;
119 
120 private:
121  SeqNumber actualSeqNum_;
122  SeqNumber expectedSeqNum_;
123  std::vector<unsigned char> buffer_;
124 };
125 
126 /**
127  * A response has not been received during the specified timeout.
128  */
130  : public SessionException
131 {
132 public:
133  explicit ResponseTimeoutException(const std::string& rejectReason, int timeoutMilliseconds)
135  , timeout_(timeoutMilliseconds)
136  {}
137 
139 
140  /// @return timeout in milliseconds
141  int timeout() const
142  {
143  return timeout_;
144  }
145 
146 private:
147  int timeout_; ///< timeout in milliseconds.
148 };
149 
150 /**
151  * The <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiate">Negotiate</a> message is rejected by the exchange.
152  */
154  : public SessionException
155 {
156 public:
158 
160 
161  std::string rejectReason() const
162  {
163  return rejectReason_;
164  }
165 
167  {
168  return errorCodes_;
169  }
170 
171 private:
172  std::string rejectReason_;
173  Messaging::ErrorCodes::Enum errorCodes_;
174 };
175 
176 /**
177  * The program is finishing its execution.
178  */
180  : public SessionException
181 {
182 public:
184 
186 };
187 
188 /// The telecommunication link cannot be established.
190  : public SessionException
191 {
192 public:
193  /// Constructor.
194  ///
195  /// \param rejectReason the telecommunication link error description.
196  /// \param cause the source exception.
197  CannotEstablishLinkException(const std::string& rejectReason, const std::exception& cause);
198 
200 };
201 
202 /// Received the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Terminate">Terminate</a> message
203 /// in reply to the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish">Establish</a> message.
205  : public SessionException
206 {
207 public:
209 
211 };
212 
213 }
214 }
215 }
216 }
217 
218 #if WIN32
219 #pragma warning(pop)
220 #endif
#define ONIXS_CONFLATEDTCP_NOTHROW
Definition: Compiler.h:189
The Negotiate message is rejected by the exchange.
Messaging::UInt32 SeqNumber
Definition: Messaging.h:58
An unexpected message sequence number is detected.
#define ONIXS_CONFLATEDTCP_EXPORTED
Definition: Compiler.h:187
ResponseTimeoutException(const std::string &rejectReason, int timeoutMilliseconds)
Received the Terminate message in reply to the Establish message.
Definition: Defines.h:40
#define ONIXS_CONFLATEDTCP_OVERRIDE
Definition: Compiler.h:193
The telecommunication link cannot be established.
A telecommunication link error is detected.
A response has not been received during the specified timeout.