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
|
// **********************************************************************
//
// Copyright (c) 2003-2009 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;
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>
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) {}
/// <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>
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) {}
}
/// <summary>
/// Base class for Ice run-time exceptions.
/// </summary>
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) {}
}
/// <summary>
/// Base class for Slice user exceptions.
/// </summary>
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) {}
public abstract void write__(IceInternal.BasicStream os__);
public abstract void read__(IceInternal.BasicStream is__, bool rid__);
public virtual void write__(Ice.OutputStream outS__)
{
Debug.Assert(false);
}
public virtual void read__(Ice.InputStream inS__, bool rid__)
{
Debug.Assert(false);
}
public virtual bool usesClasses__()
{
return false;
}
}
}
namespace IceInternal
{
public class LocalExceptionWrapper : Ice.Exception
{
public LocalExceptionWrapper(Ice.LocalException ex, bool retry)
{
_ex = ex;
_retry = retry;
}
public LocalExceptionWrapper(LocalExceptionWrapper ex)
{
_ex = ex.get();
_retry = ex._retry;
}
public override string ice_name()
{
return _ex.ice_name();
}
public Ice.LocalException get()
{
return _ex;
}
//
// If true, always repeat the request. Don't take retry settings
// or "at-most-once" guarantees into account.
//
// If false, only repeat the request if the retry settings allow
// to do so, and if "at-most-once" does not need to be guaranteed.
//
public bool retry()
{
return _retry;
}
public static void throwWrapper(System.Exception ex)
{
Ice.UserException userException = ex as Ice.UserException;
if(userException != null)
{
throw new LocalExceptionWrapper(new Ice.UnknownUserException(userException.ice_name()),
false);
}
Ice.LocalException localException = ex as Ice.LocalException;
if(localException != null)
{
if(ex is Ice.UnknownException ||
ex is Ice.ObjectNotExistException ||
ex is Ice.OperationNotExistException ||
ex is Ice.FacetNotExistException)
{
throw new LocalExceptionWrapper(localException, false);
}
throw new LocalExceptionWrapper(new Ice.UnknownLocalException(localException.ice_name()),
false);
}
throw new LocalExceptionWrapper(new Ice.UnknownException(ex.GetType().FullName), false);
}
private Ice.LocalException _ex;
private bool _retry;
}
}
|