forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExceptions.cs
executable file
·307 lines (267 loc) · 9.16 KB
/
Exceptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
namespace QuickFix
{
public class QuickFIXException : System.Exception
{
public QuickFIXException()
: base()
{ }
public QuickFIXException(string msg)
: base(msg)
{ }
public QuickFIXException(string msg, System.Exception innerException)
: base(msg, innerException)
{ }
public QuickFIXException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
: base(info, context)
{ }
}
/// <summary>
/// Application is not configured correctly
/// </summary>
public class ConfigError : QuickFIXException
{
public ConfigError(string msg)
: base("Configuration failed: " + msg)
{ }
public ConfigError(string msg, System.Exception innerException)
: base("Configuration failed: " + msg, innerException)
{ }
}
/// <summary>
/// Unable to convert field into its native format
/// </summary>
public class FieldConvertError : QuickFIXException
{
public FieldConvertError(string msg)
: base("Could not convert field: " + msg)
{ }
public FieldConvertError(string msg, System.Exception innerException)
: base("Could not convert field: " + msg, innerException)
{ }
}
/// <summary>
/// Session cannot be found for specified action
/// </summary>
public class SessionNotFound : QuickFIXException
{
public SessionNotFound(string msg)
: base("Session Not Found: " + msg)
{ }
public SessionNotFound(SessionID sessionID)
: base("Session '" + sessionID + "' Not Found")
{ }
public SessionNotFound(SessionID sessionID, string msg)
: base("Session '" + sessionID + "' Not Found: " + msg)
{ }
}
/// <summary>
/// Version of FIX is not supported
/// </summary>
public class UnsupportedVersion : QuickFIXException
{
public UnsupportedVersion()
: base("Unsupported Version")
{ }
public UnsupportedVersion(string msg)
: base("Unsupported Version: " + msg)
{ }
public UnsupportedVersion(string msg, System.Exception innerException)
: base("Unsupported Version: " + msg, innerException)
{ }
}
/// <summary>
/// Message type is not supported by application
/// </summary>
public class UnsupportedMessageType : QuickFIXException
{
public UnsupportedMessageType()
: base()
{ }
}
/// <summary>
/// Not a recognizable message
/// </summary>
[System.Serializable]
public class InvalidMessage : QuickFIXException
{
public InvalidMessage()
: base("Invalid message")
{ }
public InvalidMessage(string msg)
: base("Invalid message: " + msg)
{ }
public InvalidMessage(string msg, System.Exception innerException)
: base("Invalid message: " + msg, innerException)
{ }
public InvalidMessage(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
: base(info, context)
{ }
}
/// <summary>
/// Socket connection was reset by peer
/// </summary>
public class ConnectionResetByPeerException : QuickFIXException
{
public ConnectionResetByPeerException()
: base("Connection reset by peer")
{ }
public ConnectionResetByPeerException(System.Exception innerException)
: base("Connection reset by peer", innerException)
{ }
}
public class MessageParseError : QuickFIXException
{
public MessageParseError()
: base("Could not parse message")
{ }
public MessageParseError(string msg)
: base("Could not parse message: " + msg)
{ }
public MessageParseError(string msg, System.Exception innerException)
: base("Could not parse message: " + msg, innerException)
{ }
}
/// <summary>
/// Thrown in Application.ToApp callback to indicate that app should abort sending the message
/// </summary>
public class DoNotSend : QuickFIXException
{
public DoNotSend()
: base()
{ }
}
/// <summary>
/// Thrown in Application.FromAdmin callback to indicate that app should reject logon attempt
/// </summary>
public class RejectLogon : QuickFIXException
{
public RejectLogon(string msg)
: base("Rejected Logon Attempt: " + msg)
{ }
}
#region Tag Exceptions
/// <summary>
/// Base class for tag-related errors
/// </summary>
public abstract class TagException : QuickFIXException
{
protected int _field;
public int Field { get { return _field; } }
public FixValues.SessionRejectReason sessionRejectReason;
[System.Obsolete("For getter, use 'Field' instead. The setter should not be used at all.")]
public int field
{
get { return _field; }
set { _field = value; }
}
public TagException(string msg, int field)
: base(msg)
{
this._field = field;
this.sessionRejectReason = new QuickFix.FixValues.SessionRejectReason(FixValues.SessionRejectReason.OTHER.Value, msg);
}
public TagException(int field, FixValues.SessionRejectReason reason)
: base(reason.Description)
{
this._field = field;
this.sessionRejectReason = reason;
}
public TagException(int field, FixValues.SessionRejectReason reason, System.Exception innerException)
: base(reason.Description, innerException)
{
this._field = field;
this.sessionRejectReason = reason;
}
}
/// <summary>
/// Tag is not in the correct order
/// </summary>
public class TagOutOfOrder : TagException
{
public TagOutOfOrder(int field) : base(field, FixValues.SessionRejectReason.TAG_SPECIFIED_OUT_OF_REQUIRED_ORDER) { }
}
/// <summary>
/// Tag number does not exist in specification
/// </summary>
public class InvalidTagNumber : TagException
{
public InvalidTagNumber(int field) : base(field, FixValues.SessionRejectReason.INVALID_TAG_NUMBER) { }
}
/// <summary>
/// Required field is not in message
/// </summary>
public class RequiredTagMissing : TagException
{
public RequiredTagMissing(int field) : base(field, FixValues.SessionRejectReason.REQUIRED_TAG_MISSING) { }
}
/// <summary>
/// Field does not belong to message
/// </summary>
public class TagNotDefinedForMessage : TagException
{
public string msgType;
public TagNotDefinedForMessage(int field, string msgType) : base(field, FixValues.SessionRejectReason.TAG_NOT_DEFINED_FOR_THIS_MESSAGE_TYPE)
{
this.msgType = msgType;
}
}
/// <summary>
/// Field exists in message without a value
/// </summary>
public class NoTagValue : TagException
{
public NoTagValue(int field) : base(field, FixValues.SessionRejectReason.TAG_SPECIFIED_WITHOUT_A_VALUE) { }
}
/// <summary>
/// Field has a value that is out of range
/// </summary>
public class IncorrectTagValue : TagException
{
public IncorrectTagValue(int field) : base(field, FixValues.SessionRejectReason.VALUE_IS_INCORRECT) { }
}
/// <summary>
/// Repeated tag not part of repeating group
/// </summary>
public class RepeatedTag : TagException
{
public RepeatedTag(int field) : base(field, FixValues.SessionRejectReason.TAG_APPEARS_MORE_THAN_ONCE) { }
}
/// <summary>
/// Field has a badly formatted value
/// </summary>
public class IncorrectDataFormat : TagException
{
public IncorrectDataFormat(int field, System.Exception innerException)
: base(field, FixValues.SessionRejectReason.INCORRECT_DATA_FORMAT_FOR_VALUE, innerException)
{ }
}
public class InvalidMessageType : TagException
{
public InvalidMessageType()
: base(QuickFix.Fields.Tags.MsgType, FixValues.SessionRejectReason.INVALID_MSGTYPE)
{ }
}
public class RepeatingGroupCountMismatch : TagException
{
public RepeatingGroupCountMismatch(int tag)
:base(tag, FixValues.SessionRejectReason.INCORRECT_NUM_IN_GROUP_COUNT_FOR_REPEATING_GROUP)
{}
}
public class OtherTagException : TagException
{
public OtherTagException(string msg, int tag)
: base(msg, tag)
{ }
}
/// <summary>
/// For when a received message has a group that doesn't start its entries with the delimiter tag
/// </summary>
public class GroupDelimiterTagException : OtherTagException
{
public GroupDelimiterTagException(int counterTag, int delimiterTag)
: base(string.Format("Group {0}'s first entry does not start with delimiter {1}", counterTag,delimiterTag), counterTag)
{ }
}
#endregion
}