OnixS C++ CME iLink 3 Binary Order Entry Handler  1.9.0
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 
25 
26 #include <string>
27 
28 #if WIN32
29 #pragma warning(push)
30 #pragma warning(disable : 4275)
31 #pragma warning(disable : 4251)
32 #endif
33 
34 namespace OnixS {
35 namespace CME {
36 namespace iLink3 {
37 namespace Exceptions{
38 
39 /**
40  * A Session-related exception.
41  */
42 class ONIXS_ILINK3_EXPORTED SessionException : public std::exception
43 {
44 public:
45  SessionException(SessionErrorReason::Enum reason, const std::string& message);
46 
47  SessionException(SessionErrorReason::Enum reason, const std::string& message, const std::exception& cause);
48 
50 
51  const char* what() const ONIXS_ILINK3_NOTHROW ONIXS_ILINK3_OVERRIDE;
52 
54  {
55  return reason_;
56  }
57 
58  const std::string& toString() const
59  {
60  return message_;
61  }
62 
63 private:
64  std::string message_;
66 };
67 
68 /**
69  * An unexpected message type is received.
70  */
72  : public SessionException
73 {
74 public:
75  UnexpectedMessageTypeException(const std::string& rejectReason, Messaging::SbeMessage incomingMessage);
76 
78 
79  Messaging::SbeMessage receivedMessage() const;
80 
81 private:
82  std::vector<unsigned char> buffer_;
83 };
84 
85 /**
86  * A telecommunication link error is detected.
87  */
89  : public SessionException
90 {
91 public:
92  explicit LinkErrorException(const std::string& rejectReason);
93 
95 };
96 
97 /**
98  * An unexpected message sequence number is detected.
99  */
101  : public SessionException
102 {
103 public:
104  UnexpectedSequenceNumberException(Messaging::SbeMessage receivedMessage, const std::string& rejectReason,
105  SeqNumber actualSeqNum, SeqNumber expectedSeqNum);
106 
108 
110  {
111  return actualSeqNum_;
112  }
113 
115  {
116  return expectedSeqNum_;
117  }
118 
119  Messaging::SbeMessage receivedMessage() const;
120 
121 private:
122  SeqNumber actualSeqNum_;
123  SeqNumber expectedSeqNum_;
124  std::vector<unsigned char> buffer_;
125 };
126 
127 /**
128  * A response has not been received during the specified timeout.
129  */
131  : public SessionException
132 {
133 public:
134  explicit ResponseTimeoutException(const std::string& rejectReason, int timeoutMilliseconds)
136  , timeout_(timeoutMilliseconds)
137  {}
138 
140 
141  /// @return timeout in milliseconds
142  int timeout() const
143  {
144  return timeout_;
145  }
146 
147 private:
148  int timeout_; ///< timeout in milliseconds.
149 };
150 
151 /**
152  * The <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiate">Negotiate</a> message is rejected by the exchange.
153  */
155  : public SessionException
156 {
157 public:
159 
161 
162  std::string rejectReason() const
163  {
164  return rejectReason_;
165  }
166 
168  {
169  return errorCodes_;
170  }
171 
172 private:
173  std::string rejectReason_;
175 };
176 
177 /**
178  * The <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish">Establish</a> message is rejected by the exchange.
179  */
181  : public SessionException
182 {
183 public:
185 
187 
188  std::string rejectReason() const
189  {
190  return rejectReason_;
191  }
192 
194  {
195  return errorCodes_;
196  }
197 
198 private:
199  std::string rejectReason_;
201 };
202 
203 /**
204  * The program is finishing its execution.
205  */
207  : public SessionException
208 {
209 public:
211 
213 };
214 
215 /// The telecommunication link cannot be established.
217  : public SessionException
218 {
219 public:
220  /// Constructor.
221  ///
222  /// \param rejectReason the telecommunication link error description.
223  /// \param cause the source exception.
224  CannotEstablishLinkException(const std::string& rejectReason, const std::exception& cause);
225 
227 };
228 
229 /// Received the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Terminate">Terminate</a> message
230 /// in reply to the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish">Establish</a> message.
232  : public SessionException
233 {
234 public:
236 
238 };
239 
240 }
241 }
242 }
243 }
244 
245 #if WIN32
246 #pragma warning(pop)
247 #endif
Messaging::UInt32 SeqNumber
Definition: Messaging.h:58
#define ONIXS_ILINK3_OVERRIDE
Definition: Compiler.h:168
NegotiationRejectErrorCode::Enum errorCodes() const
Received the Terminate message in reply to the Establish message.
The Establish message is rejected by the exchange.
Definition: Defines.h:40
ResponseTimeoutException(const std::string &rejectReason, int timeoutMilliseconds)
EstablishmentRejectErrorCode::Enum errorCodes() const
A telecommunication link error is detected.
A response has not been received during the specified timeout.
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:162
The telecommunication link cannot be established.
The Negotiate message is rejected by the exchange.
SessionErrorReason::Enum reason() const
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:164
An unexpected message sequence number is detected.