| | | 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 | | { |
| | | 11 | | if (v is UnknownSlicedValue usv) |
| | | 12 | | { |
| | | 13 | | throw new MarshalException($"The Slice loader did not find a class for type ID '{usv.ice_id()}'."); |
| | | 14 | | } |
| | | 15 | | |
| | | 16 | | string type = v.ice_id(); |
| | | 17 | | string expected; |
| | | 18 | | try |
| | | 19 | | { |
| | | 20 | | expected = (string)expectedType.GetMethod("ice_staticId").Invoke(null, null); |
| | | 21 | | } |
| | | 22 | | catch (System.Exception) |
| | | 23 | | { |
| | | 24 | | expected = ""; |
| | | 25 | | Debug.Assert(false); |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | throw new MarshalException( |
| | | 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 | | { |
| | | 34 | | throw new MarshalException( |
| | | 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 | | |
| | 1 | 43 | | public RetryException(Ice.LocalException ex) => _ex = ex; |
| | | 44 | | |
| | 1 | 45 | | public Ice.LocalException get() => _ex; |
| | | 46 | | } |