|
23 | 23 | import org.msgpack.MessageTypeException; |
24 | 24 |
|
25 | 25 | abstract class Accept implements BufferReferer { |
| 26 | + private final String expected; |
| 27 | + |
| 28 | + Accept(String expected) { |
| 29 | + this.expected = expected; |
| 30 | + } |
| 31 | + |
26 | 32 | void acceptBoolean(boolean v) throws IOException { |
27 | | - throw new MessageTypeException("Unexpected boolean value"); |
| 33 | + throw new MessageTypeException(String.format("Expected %s, but got boolean", expected)); |
28 | 34 | } |
29 | 35 |
|
30 | 36 | void acceptInteger(byte v) throws IOException { |
31 | | - throw new MessageTypeException("Unexpected integer value"); |
| 37 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
32 | 38 | } |
33 | 39 |
|
34 | 40 | void acceptInteger(short v) throws IOException { |
35 | | - throw new MessageTypeException("Unexpected integer value"); |
| 41 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
36 | 42 | } |
37 | 43 |
|
38 | 44 | void acceptInteger(int v) throws IOException { |
39 | | - throw new MessageTypeException("Unexpected integer value"); |
| 45 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
40 | 46 | } |
41 | 47 |
|
42 | 48 | void acceptInteger(long v) throws IOException { |
43 | | - throw new MessageTypeException("Unexpected integer value"); |
| 49 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
44 | 50 | } |
45 | 51 |
|
46 | 52 | void acceptUnsignedInteger(byte v) throws IOException { |
47 | | - throw new MessageTypeException("Unexpected integer value"); |
| 53 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
48 | 54 | } |
49 | 55 |
|
50 | 56 | void acceptUnsignedInteger(short v) throws IOException { |
51 | | - throw new MessageTypeException("Unexpected integer value"); |
| 57 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
52 | 58 | } |
53 | 59 |
|
54 | 60 | void acceptUnsignedInteger(int v) throws IOException { |
55 | | - throw new MessageTypeException("Unexpected integer value"); |
| 61 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
56 | 62 | } |
57 | 63 |
|
58 | 64 | void acceptUnsignedInteger(long v) throws IOException { |
59 | | - throw new MessageTypeException("Unexpected integer value"); |
| 65 | + throw new MessageTypeException(String.format("Expected %s, but got integer value", expected)); |
60 | 66 | } |
61 | 67 |
|
62 | 68 | // void checkRawAcceptable() throws IOException { |
63 | 69 | // throw new MessageTypeException("Unexpected raw value"); |
64 | 70 | // } |
65 | 71 |
|
66 | 72 | void acceptRaw(byte[] raw) throws IOException { |
67 | | - throw new MessageTypeException("Unexpected raw value"); |
| 73 | + throw new MessageTypeException(String.format("Expected %s, but got raw value", expected)); |
68 | 74 | } |
69 | 75 |
|
70 | 76 | void acceptEmptyRaw() throws IOException { |
71 | | - throw new MessageTypeException("Unexpected raw value"); |
| 77 | + throw new MessageTypeException(String.format("Expected %s, but got raw value", expected)); |
72 | 78 | } |
73 | 79 |
|
74 | 80 | // void checkArrayAcceptable(int size) throws IOException { |
75 | 81 | // throw new MessageTypeException("Unexpected array value"); |
76 | 82 | // } |
77 | 83 |
|
78 | 84 | void acceptArray(int size) throws IOException { |
79 | | - throw new MessageTypeException("Unexpected array value"); |
| 85 | + throw new MessageTypeException(String.format("Expected %s, but got array value", expected)); |
80 | 86 | } |
81 | 87 |
|
82 | 88 | // void checkMapAcceptable(int size) throws IOException { |
83 | 89 | // throw new MessageTypeException("Unexpected map value"); |
84 | 90 | // } |
85 | 91 |
|
86 | 92 | void acceptMap(int size) throws IOException { |
87 | | - throw new MessageTypeException("Unexpected map value"); |
| 93 | + throw new MessageTypeException(String.format("Expected %s, but got map value", expected)); |
88 | 94 | } |
89 | 95 |
|
90 | 96 | void acceptNil() throws IOException { |
91 | | - throw new MessageTypeException("Unexpected nil value"); |
| 97 | + throw new MessageTypeException(String.format("Expected %s, but got nil value", expected)); |
92 | 98 | } |
93 | 99 |
|
94 | 100 | void acceptFloat(float v) throws IOException { |
95 | | - throw new MessageTypeException("Unexpected float value"); |
| 101 | + throw new MessageTypeException(String.format("Expected %s, but got float value", expected)); |
96 | 102 | } |
97 | 103 |
|
98 | 104 | void acceptDouble(double v) throws IOException { |
99 | | - throw new MessageTypeException("Unexpected float value"); |
| 105 | + throw new MessageTypeException(String.format("Expected %s, but got float value", expected)); |
100 | 106 | } |
101 | 107 |
|
102 | 108 | public void refer(ByteBuffer bb, boolean gift) throws IOException { |
103 | | - throw new MessageTypeException("Unexpected raw value"); |
| 109 | + throw new MessageTypeException(String.format("Expected %s, but got raw value", expected)); |
104 | 110 | } |
105 | 111 | } |
0 commit comments