/** * Returns a formatted error message for this {@link io.vertx.core.dns.DnsResponseCode}. */ @Override public String toString() { return name() + ": type " + errorCode + ", " + message; }
/** * Returns the {@link io.vertx.core.dns.DnsResponseCode} that corresponds with the given * {@code responseCode}. * * @param responseCode * the error code's id * @return corresponding {@link io.vertx.core.dns.DnsResponseCode} */ public static DnsResponseCode valueOf(int responseCode) { DnsResponseCode[] errors = DnsResponseCode.values(); for (DnsResponseCode e : errors) { if (e.errorCode == responseCode) { return e; } } return null; }
void handle(DnsResponse msg) { DnsResponseCode code = DnsResponseCode.valueOf(msg.code().intValue()); if (code == DnsResponseCode.NOERROR) { inProgressMap.remove(msg.id()); if (timerID >= 0) { vertx.cancelTimer(timerID); } int count = msg.count(DnsSection.ANSWER); List<T> records = new ArrayList<>(count); for (int idx = 0;idx < count;idx++) { DnsRecord a = msg.recordAt(DnsSection.ANSWER, idx); T record = RecordDecoder.decode(a); if (isRequestedType(a.type(), types)) { records.add(record); } } if (records.size() > 0 && (records.get(0) instanceof MxRecordImpl || records.get(0) instanceof SrvRecordImpl)) { Collections.sort((List) records); } actualCtx.executeFromIO(v -> { fut.tryComplete(records); }); } else { actualCtx.executeFromIO(new DnsException(code), this::fail); } }
void handle(DnsResponse msg) { DnsResponseCode code = DnsResponseCode.valueOf(msg.code().intValue()); if (code == DnsResponseCode.NOERROR) { inProgressMap.remove(msg.id()); if (timerID >= 0) { vertx.cancelTimer(timerID); } int count = msg.count(DnsSection.ANSWER); List<T> records = new ArrayList<>(count); for (int idx = 0;idx < count;idx++) { DnsRecord a = msg.recordAt(DnsSection.ANSWER, idx); T record = RecordDecoder.decode(a); if (isRequestedType(a.type(), types)) { records.add(record); } } if (records.size() > 0 && (records.get(0) instanceof MxRecordImpl || records.get(0) instanceof SrvRecordImpl)) { Collections.sort((List) records); } actualCtx.executeFromIO(v -> { fut.tryComplete(records); }); } else { actualCtx.executeFromIO(new DnsException(code), this::fail); } }
/** * Returns a formatted error message for this {@link io.vertx.core.dns.DnsResponseCode}. */ @Override public String toString() { return name() + ": type " + errorCode + ", " + message; }
/** * Returns the {@link io.vertx.core.dns.DnsResponseCode} that corresponds with the given * {@code responseCode}. * * @param responseCode * the error code's id * @return corresponding {@link io.vertx.core.dns.DnsResponseCode} */ public static DnsResponseCode valueOf(int responseCode) { DnsResponseCode[] errors = DnsResponseCode.values(); for (DnsResponseCode e : errors) { if (e.errorCode == responseCode) { return e; } } return null; }