1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.resolver.dns;
18
19 import io.netty.handler.codec.dns.DnsResponseCode;
20 import io.netty.util.internal.PlatformDependent;
21 import io.netty.util.internal.SuppressJava6Requirement;
22 import io.netty.util.internal.ThrowableUtil;
23
24 import java.net.UnknownHostException;
25
26
27
28
29
30 public final class DnsErrorCauseException extends RuntimeException {
31
32 private static final long serialVersionUID = 7485145036717494533L;
33
34 private final DnsResponseCode code;
35
36 private DnsErrorCauseException(String message, DnsResponseCode code) {
37 super(message);
38 this.code = code;
39 }
40
41 @SuppressJava6Requirement(reason = "uses Java 7+ Exception.<init>(String, Throwable, boolean, boolean)" +
42 " but is guarded by version checks")
43 private DnsErrorCauseException(String message, DnsResponseCode code, boolean shared) {
44 super(message, null, false, true);
45 this.code = code;
46 assert shared;
47 }
48
49
50
51 @Override
52 public Throwable fillInStackTrace() {
53 return this;
54 }
55
56
57
58
59
60
61 public DnsResponseCode getCode() {
62 return code;
63 }
64
65 static DnsErrorCauseException newStatic(String message, DnsResponseCode code, Class<?> clazz, String method) {
66 final DnsErrorCauseException exception;
67 if (PlatformDependent.javaVersion() >= 7) {
68 exception = new DnsErrorCauseException(message, code, true);
69 } else {
70 exception = new DnsErrorCauseException(message, code);
71 }
72 return ThrowableUtil.unknownStackTrace(exception, clazz, method);
73 }
74 }