Exceptions.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /****************************************************************************
4 ** Copyright (c) 2001-2014
5 **
6 ** This file is part of the QuickFIX FIX Engine
7 **
8 ** This file may be distributed under the terms of the quickfixengine.org
9 ** license as defined by quickfixengine.org and appearing in the file
10 ** LICENSE included in the packaging of this file.
11 **
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 **
15 ** See http://www.quickfixengine.org/LICENSE for licensing information.
16 **
17 ** Contact ask@quickfixengine.org if any conditions of this licensing are
18 ** not clear to you.
19 **
20 ****************************************************************************/
21 
22 #ifndef FIX_EXCEPTIONS_H
23 #define FIX_EXCEPTIONS_H
24 
25 #include <string>
26 #include <stdexcept>
27 #include "Utility.h"
28 
29 namespace FIX
30 {
31 
33 struct Exception : public std::logic_error
34 {
35  Exception( const std::string& t, const std::string& d )
36  : std::logic_error( d.size() ? t + ": " + d : t ),
37  type( t ), detail( d )
38  {}
39  ~Exception() throw() {}
40 
41  std::string type;
42  std::string detail;
43 };
44 
46 struct DataDictionaryNotFound : public Exception
47 {
48  DataDictionaryNotFound( const std::string& v, const std::string& what = "" )
49  : Exception( "Could not find data dictionary", what ),
50  version( v ) {}
51  ~DataDictionaryNotFound() throw() {}
52 
53  std::string version;
54 };
55 
57 struct FieldNotFound : public Exception
58 {
59  FieldNotFound( int f = 0, const std::string& what = "" )
60  : Exception( "Field not found", what ),
61  field( f ) {}
62  int field;
63 };
64 
66 struct FieldConvertError : public Exception
67 {
68  FieldConvertError( const std::string& what = "" )
69  : Exception( "Could not convert field", what ) {}
70 };
71 
74 {
75  MessageParseError( const std::string& what = "" )
76  : Exception( "Could not parse message", what ) {}
77 };
78 
80 struct InvalidMessage : public Exception
81 {
82  InvalidMessage( const std::string& what = "" )
83  : Exception( "Invalid message", what ) {}
84 };
85 
87 struct ConfigError : public Exception
88 {
89  ConfigError( const std::string& what = "" )
90  : Exception( "Configuration failed", what ) {}
91 };
92 
94 struct RuntimeError : public Exception
95 {
96  RuntimeError( const std::string& what = "" )
97  : Exception( "Runtime error", what ) {}
98 };
99 
101 struct InvalidTagNumber : public Exception
102 {
103  InvalidTagNumber( int f = 0, const std::string& what = "" )
104  : Exception( "Invalid tag number", what ),
105  field( f ) {}
106  int field;
107 };
108 
110 struct RequiredTagMissing : public Exception
111 {
112  RequiredTagMissing( int f = 0, const std::string& what = "" )
113  : Exception( "Required tag missing", what ),
114  field( f ) {}
115  int field;
116 };
117 
119 struct TagNotDefinedForMessage : public Exception
120 {
121  TagNotDefinedForMessage( int f = 0, const std::string& what = "" )
122  : Exception( "Tag not defined for this message type", what ),
123  field( f ) {}
124  int field;
125 };
126 
128 struct NoTagValue : public Exception
129 {
130  NoTagValue( int f = 0, const std::string& what = "" )
131  : Exception( "Tag specified without a value", what ),
132  field( f ) {}
133  int field;
134 };
135 
137 struct IncorrectTagValue : public Exception
138 {
139  IncorrectTagValue( int f = 0, const std::string& what = "" )
140  : Exception( "Value is incorrect (out of range) for this tag", what ),
141  field( f ) {}
142  int field;
143 };
144 
146 struct IncorrectDataFormat : public Exception
147 {
148  IncorrectDataFormat( int f = 0, const std::string& what = "" )
149  : Exception( "Incorrect data format for value", what ),
150  field( f ) {}
151  int field;
152 };
153 
155 struct IncorrectMessageStructure : public Exception
156 {
157  IncorrectMessageStructure( const std::string& what = "" )
158  : Exception( "Incorrect message structure", what ) {}
159 };
160 
162 struct DuplicateFieldNumber : public Exception
163 {
164  DuplicateFieldNumber( const std::string& what = "" )
165  : Exception( "Duplicate field number", what ) {}
166 };
167 
169 struct InvalidMessageType : public Exception
170 {
171  InvalidMessageType( const std::string& what = "" )
172  : Exception( "Invalid Message Type", what ) {}
173 };
174 
176 struct UnsupportedMessageType : public Exception
177 {
178  UnsupportedMessageType( const std::string& what = "" )
179  : Exception( "Unsupported Message Type", what ) {}
180 };
181 
183 struct UnsupportedVersion : public Exception
184 {
185  UnsupportedVersion( const std::string& what = "" )
186  : Exception( "Unsupported Version", what ) {}
187 };
188 
190 struct TagOutOfOrder : public Exception
191 {
192  TagOutOfOrder( int f = 0, const std::string& what = "" )
193  : Exception( "Tag specified out of required order", what ),
194  field( f ) {}
195  int field;
196 };
197 
199 struct RepeatedTag : public Exception
200 {
201  RepeatedTag( int f = 0, const std::string& what = "" )
202  : Exception( "Repeated tag not part of repeating group", what ),
203  field( f ) {}
204  int field;
205 };
206 
208 struct RepeatingGroupCountMismatch : public Exception
209 {
210  RepeatingGroupCountMismatch( int f = 0, const std::string& what = "" )
211  : Exception( "Repeating group count mismatch", what ),
212  field( f ) {}
213  int field;
214 };
215 
217 struct DoNotSend : public Exception
218 {
219  DoNotSend( const std::string& what = "" )
220  : Exception( "Do Not Send Message", what ) {}
221 };
222 
224 struct RejectLogon : public Exception
225 {
226  RejectLogon( const std::string& what = "" )
227  : Exception( "Rejected Logon Attempt", what ) {}
228 };
229 
231 struct SessionNotFound : public Exception
232 {
233  SessionNotFound( const std::string& what = "" )
234  : Exception( "Session Not Found", what ) {}
235 };
236 
238 struct IOException : public Exception
239 {
240  IOException( const std::string& what = "" )
241  : Exception( "IO Error", what ) {}
242 };
243 
245 struct SocketException : public Exception
246 {
248  : Exception( "Socket Error", errorToWhat() ) {}
249 
250  SocketException( const std::string& what )
251  : Exception( "Socket Error", what ) {}
252 
253  static std::string errorToWhat()
254  {
255 #ifdef _MSC_VER
256  int error = WSAGetLastError();
257  char buffer[2048];
258  FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,
259  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
260  buffer, 2048, NULL );
261  return buffer;
262 #else
263  int error = errno;
264  return strerror( error );
265 #endif
266  }
267 };
268 
271 {
272  SocketSendFailed() {}
273  SocketSendFailed( const std::string& what )
274  : SocketException( what ) {}
275 };
276 
278 struct SocketRecvFailed : public SocketException
279 {
280  SocketRecvFailed( ssize_t size )
281  : SocketException( size == 0 ? "Connection reset by peer." : size < 0 ? errorToWhat() : "Success." ) {}
282  SocketRecvFailed( const std::string& what )
283  : SocketException( what ) {}
284 };
285 
288 {
290  SocketCloseFailed( const std::string& what )
291  : SocketException( what ) {}
292 };
293 
295 }
296 
297 #endif //FIX_EXCEPTIONS_H
FIX::RepeatedTag::field
int field
Definition: Exceptions.h:221
FIX::RequiredTagMissing::field
int field
Definition: Exceptions.h:132
FIX::DoNotSend::DoNotSend
DoNotSend(const std::string &what="")
Definition: Exceptions.h:236
FIX::SocketException::errorToWhat
static std::string errorToWhat()
Definition: Exceptions.h:270
FIX::Exception
Base QuickFIX exception type.
Definition: Exceptions.h:50
FIX::RepeatingGroupCountMismatch::field
int field
Definition: Exceptions.h:230
FIX::SocketException
Socket Error.
Definition: Exceptions.h:262
FIX::UnsupportedVersion::UnsupportedVersion
UnsupportedVersion(const std::string &what="")
Definition: Exceptions.h:202
FIX::SocketRecvFailed::SocketRecvFailed
SocketRecvFailed(ssize_t size)
Definition: Exceptions.h:297
FIX::UnsupportedVersion
Version of FIX is not supported.
Definition: Exceptions.h:200
FIX::RuntimeError::RuntimeError
RuntimeError(const std::string &what="")
Definition: Exceptions.h:113
FIX::SocketCloseFailed
Socket close operation failed.
Definition: Exceptions.h:304
FIX::SocketException::SocketException
SocketException()
Definition: Exceptions.h:264
FIX::FieldNotFound::field
int field
Definition: Exceptions.h:79
FIX::SocketSendFailed
Socket send operation failed.
Definition: Exceptions.h:287
FIX::ConfigError
Application is not configured correctly
Definition: Exceptions.h:104
FIX::RuntimeError
Application encountered serious error during runtime
Definition: Exceptions.h:111
FIX::InvalidMessageType::InvalidMessageType
InvalidMessageType(const std::string &what="")
Definition: Exceptions.h:188
FIX::FieldConvertError::FieldConvertError
FieldConvertError(const std::string &what="")
Definition: Exceptions.h:85
FIX::IOException
IO Error.
Definition: Exceptions.h:255
FIX::FieldConvertError
Unable to convert field into its native format.
Definition: Exceptions.h:83
FIX::TagNotDefinedForMessage::TagNotDefinedForMessage
TagNotDefinedForMessage(int f=0, const std::string &what="")
Definition: Exceptions.h:138
FIX::DataDictionaryNotFound::DataDictionaryNotFound
DataDictionaryNotFound(const std::string &v, const std::string &what="")
Definition: Exceptions.h:65
FIX::DataDictionaryNotFound::version
std::string version
Definition: Exceptions.h:70
FIX::IncorrectTagValue::IncorrectTagValue
IncorrectTagValue(int f=0, const std::string &what="")
Definition: Exceptions.h:156
FIX::FieldNotFound::FieldNotFound
FieldNotFound(int f=0, const std::string &what="")
Definition: Exceptions.h:76
FIX::RequiredTagMissing
Required field is not in message.
Definition: Exceptions.h:127
FIX::MessageParseError::MessageParseError
MessageParseError(const std::string &what="")
Definition: Exceptions.h:92
FIX::IncorrectDataFormat::IncorrectDataFormat
IncorrectDataFormat(int f=0, const std::string &what="")
Definition: Exceptions.h:165
FIX::IncorrectTagValue::field
int field
Definition: Exceptions.h:159
FIX::DataDictionaryNotFound::~DataDictionaryNotFound
~DataDictionaryNotFound()
Definition: Exceptions.h:68
FIX::IOException::IOException
IOException(const std::string &what="")
Definition: Exceptions.h:257
FIX::InvalidTagNumber
Tag number does not exist in specification.
Definition: Exceptions.h:118
FIX::TagOutOfOrder::field
int field
Definition: Exceptions.h:212
FIX::InvalidTagNumber::InvalidTagNumber
InvalidTagNumber(int f=0, const std::string &what="")
Definition: Exceptions.h:120
FIX::NoTagValue::NoTagValue
NoTagValue(int f=0, const std::string &what="")
Definition: Exceptions.h:147
FIX::UnsupportedMessageType::UnsupportedMessageType
UnsupportedMessageType(const std::string &what="")
Definition: Exceptions.h:195
FIX::NoTagValue::field
int field
Definition: Exceptions.h:150
FIX::Exception::type
std::string type
Definition: Exceptions.h:75
FIX::ConfigError::ConfigError
ConfigError(const std::string &what="")
Definition: Exceptions.h:106
FIX
Definition: Acceptor.cpp:34
FIX::RejectLogon
User wants to reject permission to logon.
Definition: Exceptions.h:241
FIX::MessageParseError
Unable to parse message.
Definition: Exceptions.h:90
FIX::RepeatingGroupCountMismatch::RepeatingGroupCountMismatch
RepeatingGroupCountMismatch(int f=0, const std::string &what="")
Definition: Exceptions.h:227
FIX::RepeatedTag::RepeatedTag
RepeatedTag(int f=0, const std::string &what="")
Definition: Exceptions.h:218
FIX::InvalidMessage::InvalidMessage
InvalidMessage(const std::string &what="")
Definition: Exceptions.h:99
FIX::RejectLogon::RejectLogon
RejectLogon(const std::string &what="")
Definition: Exceptions.h:243
FIX::TagNotDefinedForMessage::field
int field
Definition: Exceptions.h:141
FIX::UnsupportedMessageType
Message type not supported by application.
Definition: Exceptions.h:193
FIX::SocketCloseFailed::SocketCloseFailed
SocketCloseFailed()
Definition: Exceptions.h:306
FIX::Exception::Exception
Exception(const std::string &t, const std::string &d)
Definition: Exceptions.h:69
FIX::TagOutOfOrder::TagOutOfOrder
TagOutOfOrder(int f=0, const std::string &what="")
Definition: Exceptions.h:209
FIX::SocketRecvFailed
Socket recv operation failed.
Definition: Exceptions.h:295
FIX::DuplicateFieldNumber
Field shows up twice in the message.
Definition: Exceptions.h:179
FIX::RequiredTagMissing::RequiredTagMissing
RequiredTagMissing(int f=0, const std::string &what="")
Definition: Exceptions.h:129
FIX::Exception::~Exception
~Exception()
Definition: Exceptions.h:73
FIX::SessionNotFound::SessionNotFound
SessionNotFound(const std::string &what="")
Definition: Exceptions.h:250
FIX::DuplicateFieldNumber::DuplicateFieldNumber
DuplicateFieldNumber(const std::string &what="")
Definition: Exceptions.h:181
FIX::Exception::detail
std::string detail
Definition: Exceptions.h:76
FIX::InvalidTagNumber::field
int field
Definition: Exceptions.h:123
FIX::TagOutOfOrder
Tag is not in the correct order.
Definition: Exceptions.h:207
Utility.h
FIX::IncorrectMessageStructure::IncorrectMessageStructure
IncorrectMessageStructure(const std::string &what="")
Definition: Exceptions.h:174
FIX::RepeatedTag
Repeated tag not part of repeating group.
Definition: Exceptions.h:216
FIX::SocketSendFailed::SocketSendFailed
SocketSendFailed()
Definition: Exceptions.h:289
FIX::IncorrectDataFormat::field
int field
Definition: Exceptions.h:168

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001