OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.9
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 ONIXS_ILINK3_NOTHROW
59  {
60  return message_;
61  }
62 
63 private:
64  std::string message_;
66 };
67 
68 
70  : public SessionException
71 {
72 public:
73  SbeMessageAttachedExceptionBase(SessionErrorReason::Enum reason, const std::string& message, Messaging::SbeMessage sbeMessage);
74 
75  Messaging::SbeMessage receivedMessage() const;
76 
78 
79 private:
80  std::vector<unsigned char> buffer_;
81 };
82 
83 template <typename MessageType>
85 {
86 public:
88  : SbeMessageAttachedExceptionBase(reason, message, sbeMessage)
89  {}
90 
91  MessageType receivedMessage() const
92  {
93  return Messaging::typify<MessageType>(SbeMessageAttachedExceptionBase::receivedMessage());
94  }
95 };
96 
97 /**
98  * An unexpected message type is received.
99  */
102 {
103 public:
105 
106  Messaging::MessageTemplateId templateId() const;
107 
109 };
110 
111 /**
112  * A telecommunication link error is detected.
113  */
115  : public SessionException
116 {
117 public:
118  explicit LinkErrorException(const std::string& rejectReason);
119 
121 };
122 
123 /**
124  * An unexpected message sequence number is detected.
125  */
128 {
129 public:
130  UnexpectedSequenceNumberException(Messaging::SbeMessage receivedMessage, const std::string& rejectReason,
131  SeqNumber actualSeqNum, SeqNumber expectedSeqNum, Messaging::UInt64 uuid);
132 
134 
136  {
137  return actualSeqNum_;
138  }
139 
141  {
142  return expectedSeqNum_;
143  }
144 
146  {
147  return uuid_;
148  }
149 
150 private:
151  SeqNumber actualSeqNum_;
152  SeqNumber expectedSeqNum_;
153  Messaging::UInt64 uuid_;
154 };
155 
156 /**
157  * A response has not been received during the specified timeout.
158  */
160  : public SessionException
161 {
162 public:
163  explicit ResponseTimeoutException(const std::string& rejectReason, int timeoutMilliseconds)
164  : SessionException(SessionErrorReason::LinkErrorIsDetected, rejectReason)
165  , timeout_(timeoutMilliseconds)
166  {}
167 
169 
170  /// @return timeout in milliseconds
172  {
173  return timeout_;
174  }
175 
176 private:
177  int timeout_; ///< timeout in milliseconds.
178 };
179 
180 
181 /**
182  * The program is finishing its execution.
183  */
185  : public SessionException
186 {
187 public:
189 
191 };
192 
193 /// The telecommunication link cannot be established.
195  : public SessionException
196 {
197 public:
198  /// Constructor.
199  ///
200  /// \param errCode system error code (if present).
201  /// \param rejectReason the telecommunication link error description.
202  CannotEstablishLinkException(int errCode, const std::string& rejectReason);
203 
205 
206  int errCode() const ONIXS_ILINK3_NOTHROW;
207 
208 private:
209  int errCode_;
210 };
211 
212 
213 /**
214  * The <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiate">Negotiate</a> message is rejected by the exchange.
215  */
217  : public TypedSbeMessageAttachedExceptionBase<Messaging::NegotiationReject502>
218 {
219 public:
221 
223 
224  NegotiationRejectErrorCode::Enum errorCodes() const;
225 
226  std::string rejectReason() const;
227 };
228 
229 /**
230  * The <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish">Establish</a> message is rejected by the exchange.
231  */
233  : public TypedSbeMessageAttachedExceptionBase<Messaging::EstablishmentReject505>
234 {
235 public:
237 
239 
240  std::string rejectReason() const;
241 
242  EstablishmentRejectErrorCode::Enum errorCodes() const;
243 };
244 
245 /// Received the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Terminate">Terminate</a> message
246 /// in reply to the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish">Establish</a> or
247 /// <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiate">Negotiate</a> messages.
249  : public TypedSbeMessageAttachedExceptionBase<Messaging::Terminate507>
250 {
251 public:
253 
255 
256  TerminateErrorCode::Enum errorCodes() const;
257 
258  std::string terminateReason() const;
259 };
260 
261 /// Received the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Business+Reject">BusinessReject</a> message
262 /// in reply to the <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish">Establish</a> or
263 /// <a href="https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiate">Negotiate</a> messages.
265  : public TypedSbeMessageAttachedExceptionBase<Messaging::BusinessReject521>
266 {
267 public:
269 
271 
272  BusinessRejectReason::Enum errorCodes() const;
273 
274  std::string rejectReason() const;
275 };
276 
277 
278 
279 
280 }
281 }
282 }
283 }
284 
285 #if WIN32
286 #pragma warning(pop)
287 #endif
MessageHeader::TemplateId MessageTemplateId
Message type (template) identification.
Messaging::UInt32 SeqNumber
Definition: Messaging.h:60
#define ONIXS_ILINK3_OVERRIDE
Definition: Compiler.h:180
TypedSbeMessageAttachedExceptionBase(SessionErrorReason::Enum reason, const std::string &message, Messaging::SbeMessage sbeMessage)
Received the Terminate message in reply to the Establish or Negotiate messages.
The Establish message is rejected by the exchange.
Definition: Defines.h:40
#define ONIXS_ILINK3_DEFAULT
Definition: Compiler.h:202
ResponseTimeoutException(const std::string &rejectReason, int timeoutMilliseconds)
A telecommunication link error is detected.
A response has not been received during the specified timeout.
const std::string & toString() const noexcept
Received the BusinessReject message in reply to the Establish or Negotiate messages.
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:175
The telecommunication link cannot be established.
UInt64 UInt64
uInt64.
Definition: Fields.h:308
The Negotiate message is rejected by the exchange.
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:176
SessionErrorReason::Enum reason() const noexcept
An unexpected message sequence number is detected.