1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.handler.codec;
17
18
19
20
21 public class UnsupportedMessageTypeException extends CodecException {
22
23 private static final long serialVersionUID = 2799598826487038726L;
24
25 public UnsupportedMessageTypeException(
26 Object message, Class<?>... expectedTypes) {
27 super(message(
28 message == null? "null" : message.getClass().getName(), expectedTypes));
29 }
30
31 public UnsupportedMessageTypeException() { }
32
33 public UnsupportedMessageTypeException(String message, Throwable cause) {
34 super(message, cause);
35 }
36
37 public UnsupportedMessageTypeException(String s) {
38 super(s);
39 }
40
41 public UnsupportedMessageTypeException(Throwable cause) {
42 super(cause);
43 }
44
45 private static String message(
46 String actualType, Class<?>... expectedTypes) {
47 StringBuilder buf = new StringBuilder(actualType);
48
49 if (expectedTypes != null && expectedTypes.length > 0) {
50 buf.append(" (expected: ").append(expectedTypes[0].getName());
51 for (int i = 1; i < expectedTypes.length; i ++) {
52 Class<?> t = expectedTypes[i];
53 if (t == null) {
54 break;
55 }
56 buf.append(", ").append(t.getName());
57 }
58 buf.append(')');
59 }
60
61 return buf.toString();
62 }
63 }