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
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Serialization;
namespace IceInternal
{
public class Ex
{
public static void throwUOE(string expectedType, string actualType)
{
throw new Ice.UnexpectedObjectException(
"expected element of type `" + expectedType + "' but received '" + actualType,
actualType, expectedType);
}
public static void throwMemoryLimitException(int requested, int maximum)
{
throw new Ice.MemoryLimitException("requested " + requested + " bytes, maximum allowed is " + maximum +
" bytes (see Ice.MessageSizeMax)");
}
}
}
namespace Ice
{
/// <summary>
/// Base class for Ice exceptions.
/// </summary>
#if !SILVERLIGHT
[System.Serializable]
#endif
public abstract class Exception : System.Exception, System.ICloneable
{
/// <summary>
/// Creates and returns a copy of this exception.
/// </summary>
/// <returns>A copy of this exception.</returns>
public object Clone()
{
return MemberwiseClone();
}
/// <summary>
/// Creates a default-initialized exception.
/// </summary>
public Exception() {}
/// <summary>
/// Creates a default-initialized exception and sets the InnerException
/// property to the passed exception.
/// </summary>
/// <param name="ex">The inner exception.</param>
public Exception(System.Exception ex) : base("", ex) {}
#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the exception with serialized data.
/// </summary>
/// <param name="info">Holds the serialized object data about the exception being thrown.</param>
/// <param name="context">Contains contextual information about the source or destination.</param>
protected Exception(SerializationInfo info, StreamingContext context) : base(info, context) {}
#endif
/// <summary>
/// Returns the name of this exception.
/// </summary>
/// <returns>The name of this exception.</returns>
public abstract string ice_name();
/// <summary>
/// Returns a string representation of this exception, including
/// any inner exceptions.
/// </summary>
/// <returns>The string representation of this exception.</returns>
public override string ToString()
{
//
// This prints the exception Java style. That is, the outermost
// exception, "Caused by:" to the innermost exception. The
// stack trace is not nicely indented as with Java, but
// without string parsing (perhaps tokenize on "\n"), it
// doesn't appear to be possible to reformat it.
//
System.IO.StringWriter sw = new System.IO.StringWriter(CultureInfo.CurrentCulture);
IceUtilInternal.OutputBase op = new IceUtilInternal.OutputBase(sw);
op.setUseTab(false);
op.print(GetType().FullName);
op.inc();
IceInternal.ValueWriter.write(this, op);
sw.Write("\n");
sw.Write(StackTrace);
System.Exception curr = InnerException;
while(curr != null)
{
sw.Write("\nCaused by: ");
sw.Write(curr.GetType().FullName);
if(!(curr is Ice.Exception))
{
sw.Write(": ");
sw.Write(curr.Message);
}
sw.Write("\n");
sw.Write(curr.StackTrace);
curr = curr.InnerException;
}
return sw.ToString();
}
}
/// <summary>
/// Base class for local exceptions.
/// </summary>
#if !SILVERLIGHT
[System.Serializable]
#endif
public abstract class LocalException : Exception
{
/// <summary>
/// Creates a default-initialized local exception.
/// </summary>
public LocalException() {}
/// <summary>
/// Creates a default-initialized local exception and sets the InnerException
/// property to the passed exception.
/// </summary>
/// <param name="ex">The inner exception.</param>
public LocalException(System.Exception ex) : base(ex) {}
#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the exception with serialized data.
/// </summary>
/// <param name="info">Holds the serialized object data about the exception being thrown.</param>
/// <param name="context">Contains contextual information about the source or destination.</param>
protected LocalException(SerializationInfo info, StreamingContext context) : base(info, context) {}
#endif
}
/// <summary>
/// Base class for Ice run-time exceptions.
/// </summary>
#if !SILVERLIGHT
[System.Serializable]
#endif
public abstract class SystemException : Exception
{
/// <summary>
/// Creates a default-initialized run-time exception.
/// </summary>
public SystemException() {}
/// <summary>
/// Creates a default-initialized run-time exception and sets the InnerException
/// property to the passed exception.
/// </summary>
/// <param name="ex">The inner exception.</param>
public SystemException(System.Exception ex) : base(ex) {}
#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the exception with serialized data.
/// </summary>
/// <param name="info">Holds the serialized object data about the exception being thrown.</param>
/// <param name="context">Contains contextual information about the source or destination.</param>
protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context) {}
#endif
}
/// <summary>
/// Base class for Slice user exceptions.
/// </summary>
#if !SILVERLIGHT
[System.Serializable]
#endif
public abstract class UserException : Exception
{
/// <summary>
/// Creates a default-initialized user exception.
/// </summary>
public UserException() {}
/// <summary>
/// Creates a default-initialized user exception and sets the InnerException
/// property to the passed exception.
/// </summary>
/// <param name="ex">The inner exception.</param>
public UserException(System.Exception ex) : base(ex) {}
#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the exception with serialized data.
/// </summary>
/// <param name="info">Holds the serialized object data about the exception being thrown.</param>
/// <param name="context">Contains contextual information about the source or destination.</param>
protected UserException(SerializationInfo info, StreamingContext context) : base(info, context) {}
#endif
public virtual void write__(IceInternal.BasicStream os__)
{
os__.startWriteException(null);
writeImpl__(os__);
os__.endWriteException();
}
public virtual void read__(IceInternal.BasicStream is__)
{
is__.startReadException();
readImpl__(is__);
is__.endReadException(false);
}
public virtual void write__(OutputStream os__)
{
os__.startException(null);
writeImpl__(os__);
os__.endException();
}
public virtual void read__(InputStream is__)
{
is__.startException();
readImpl__(is__);
is__.endException(false);
}
public virtual bool usesClasses__()
{
return false;
}
protected abstract void writeImpl__(IceInternal.BasicStream os__);
protected abstract void readImpl__(IceInternal.BasicStream is__);
protected virtual void writeImpl__(OutputStream os__)
{
throw new MarshalException("exception was not generated with stream support");
}
protected virtual void readImpl__(InputStream is__)
{
throw new MarshalException("exception was not generated with stream support");
}
}
}
namespace IceInternal
{
public class RetryException : System.Exception
{
public RetryException(Ice.LocalException ex)
{
_ex = ex;
}
public Ice.LocalException get()
{
return _ex;
}
private Ice.LocalException _ex;
}
}
|