| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using System.Diagnostics; |
| | 4 | |
|
| | 5 | | namespace Ice.Internal; |
| | 6 | |
|
| | 7 | | public static class Ex |
| | 8 | | { |
| | 9 | | public static void throwUOE(Type expectedType, Ice.Value v) |
| | 10 | | { |
| 1 | 11 | | if (v is UnknownSlicedValue usv) |
| | 12 | | { |
| 0 | 13 | | throw new MarshalException($"The Slice loader did not find a class for type ID '{usv.ice_id()}'."); |
| | 14 | | } |
| | 15 | |
|
| 1 | 16 | | string type = v.ice_id(); |
| | 17 | | string expected; |
| | 18 | | try |
| | 19 | | { |
| 1 | 20 | | expected = (string)expectedType.GetMethod("ice_staticId").Invoke(null, null); |
| 1 | 21 | | } |
| 0 | 22 | | catch (System.Exception) |
| | 23 | | { |
| 0 | 24 | | expected = ""; |
| | 25 | | Debug.Assert(false); |
| 0 | 26 | | } |
| | 27 | |
|
| 1 | 28 | | throw new MarshalException( |
| 1 | 29 | | $"Failed to unmarshal class with type ID '{expected}': the Slice loader returned class with type ID '{type}' |
| | 30 | | } |
| | 31 | |
|
| | 32 | | public static void throwMemoryLimitException(int requested, int maximum) |
| | 33 | | { |
| 1 | 34 | | throw new MarshalException( |
| 1 | 35 | | $"Cannot unmarshal Ice message: the message size of {requested} bytes exceeds the maximum allowed of {maximu |
| | 36 | | } |
| | 37 | | } |
| | 38 | |
|
| | 39 | | public class RetryException : System.Exception |
| | 40 | | { |
| | 41 | | private readonly Ice.LocalException _ex; |
| | 42 | |
|
| | 43 | | public RetryException(Ice.LocalException ex) => _ex = ex; |
| | 44 | |
|
| | 45 | | public Ice.LocalException get() => _ex; |
| | 46 | | } |