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 
47 {
48  DataDictionaryNotFound( const std::string& v, const std::string& what = "" )
49  : Exception( "Could not find data dictionary", what ),
50  version( v ) {}
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 
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 
102 {
103  InvalidTagNumber( int f = 0, const std::string& what = "" )
104  : Exception( "Invalid tag number", what ),
105  field( f ) {}
106  int field;
107 };
108 
111 {
112  RequiredTagMissing( int f = 0, const std::string& what = "" )
113  : Exception( "Required tag missing", what ),
114  field( f ) {}
115  int field;
116 };
117 
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 
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 
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 
156 {
157  IncorrectMessageStructure( const std::string& what = "" )
158  : Exception( "Incorrect message structure", what ) {}
159 };
160 
163 {
164  DuplicateFieldNumber( const std::string& what = "" )
165  : Exception( "Duplicate field number", what ) {}
166 };
167 
170 {
171  InvalidMessageType( const std::string& what = "" )
172  : Exception( "Invalid Message Type", what ) {}
173 };
174 
177 {
178  UnsupportedMessageType( const std::string& what = "" )
179  : Exception( "Unsupported Message Type", what ) {}
180 };
181 
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 
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  std::string errorToWhat()
254  {
255 #ifdef _MSC_VER
256  error = WSAGetLastError();
257  char buffer[2048];
258  FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,
259  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
260  buffer, 2048, NULL );
261  return buffer;
262 #else
263  error = errno;
264  return strerror( error );
265 #endif
266  }
267 
268  int error;
269 };
270 
273 {
275  SocketSendFailed( const std::string& what )
276  : SocketException( what ) {}
277 };
278 
281 {
282  SocketRecvFailed( int size )
283  : SocketException( size == 0 ? "Connection reset by peer." : size < 0 ? errorToWhat() : "Success." ) {}
284  SocketRecvFailed( const std::string& what )
285  : SocketException( what ) {}
286 };
287 
290 {
292  SocketCloseFailed( const std::string& what )
293  : SocketException( what ) {}
294 };
295 
297 }
298 
299 #endif //FIX_EXCEPTIONS_H
RepeatingGroupCountMismatch(int f=0, const std::string &what="")
Definition: Exceptions.h:210
Unable to convert field into its native format.
Definition: Exceptions.h:66
Field has a badly formatted value.
Definition: Exceptions.h:146
Message type not supported by application.
Definition: Exceptions.h:176
IncorrectTagValue(int f=0, const std::string &what="")
Definition: Exceptions.h:139
Repeated group count not equal to actual count.
Definition: Exceptions.h:208
Unable to parse message.
Definition: Exceptions.h:73
Repeated tag not part of repeating group.
Definition: Exceptions.h:199
Session cannot be found for specified action.
Definition: Exceptions.h:231
RejectLogon(const std::string &what="")
Definition: Exceptions.h:226
RepeatedTag(int f=0, const std::string &what="")
Definition: Exceptions.h:201
SocketCloseFailed(const std::string &what)
Definition: Exceptions.h:292
DataDictionary not found for BeginString or ApplVerID.
Definition: Exceptions.h:46
NoTagValue(int f=0, const std::string &what="")
Definition: Exceptions.h:130
Message is not structured correctly.
Definition: Exceptions.h:155
std::string detail
Definition: Exceptions.h:42
DoNotSend(const std::string &what="")
Definition: Exceptions.h:219
Exception(const std::string &t, const std::string &d)
Definition: Exceptions.h:35
Tag number does not exist in specification.
Definition: Exceptions.h:101
FieldNotFound(int f=0, const std::string &what="")
Definition: Exceptions.h:59
InvalidTagNumber(int f=0, const std::string &what="")
Definition: Exceptions.h:103
Socket recv operation failed.
Definition: Exceptions.h:280
UnsupportedVersion(const std::string &what="")
Definition: Exceptions.h:185
SocketRecvFailed(const std::string &what)
Definition: Exceptions.h:284
Not a known message type.
Definition: Exceptions.h:169
Application encountered serious error during runtime
Definition: Exceptions.h:94
Application is not configured correctly
Definition: Exceptions.h:87
Version of FIX is not supported.
Definition: Exceptions.h:183
Field shows up twice in the message.
Definition: Exceptions.h:162
MessageParseError(const std::string &what="")
Definition: Exceptions.h:75
InvalidMessage(const std::string &what="")
Definition: Exceptions.h:82
Tag is not in the correct order.
Definition: Exceptions.h:190
IncorrectDataFormat(int f=0, const std::string &what="")
Definition: Exceptions.h:148
Field not found inside a message.
Definition: Exceptions.h:57
std::string type
Definition: Exceptions.h:41
DuplicateFieldNumber(const std::string &what="")
Definition: Exceptions.h:164
SessionNotFound(const std::string &what="")
Definition: Exceptions.h:233
Socket close operation failed.
Definition: Exceptions.h:289
RuntimeError(const std::string &what="")
Definition: Exceptions.h:96
SocketSendFailed(const std::string &what)
Definition: Exceptions.h:275
Indicates user does not want to send a message.
Definition: Exceptions.h:217
Socket Error.
Definition: Exceptions.h:245
SocketRecvFailed(int size)
Definition: Exceptions.h:282
RequiredTagMissing(int f=0, const std::string &what="")
Definition: Exceptions.h:112
SocketException(const std::string &what)
Definition: Exceptions.h:250
FieldConvertError(const std::string &what="")
Definition: Exceptions.h:68
IncorrectMessageStructure(const std::string &what="")
Definition: Exceptions.h:157
IOException(const std::string &what="")
Definition: Exceptions.h:240
Required field is not in message.
Definition: Exceptions.h:110
Field exists in message without a value.
Definition: Exceptions.h:128
Field has a value that is out of range.
Definition: Exceptions.h:137
ConfigError(const std::string &what="")
Definition: Exceptions.h:89
Not a recognizable message.
Definition: Exceptions.h:80
User wants to reject permission to logon.
Definition: Exceptions.h:224
std::string errorToWhat()
Definition: Exceptions.h:253
Field does not belong to message.
Definition: Exceptions.h:119
TagOutOfOrder(int f=0, const std::string &what="")
Definition: Exceptions.h:192
UnsupportedMessageType(const std::string &what="")
Definition: Exceptions.h:178
IO Error.
Definition: Exceptions.h:238
Socket send operation failed.
Definition: Exceptions.h:272
DataDictionaryNotFound(const std::string &v, const std::string &what="")
Definition: Exceptions.h:48
Base QuickFIX exception type.
Definition: Exceptions.h:33
TagNotDefinedForMessage(int f=0, const std::string &what="")
Definition: Exceptions.h:121
InvalidMessageType(const std::string &what="")
Definition: Exceptions.h:171

Generated on Sat Mar 29 2014 15:13:31 for QuickFIX by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2001