Skip to content

Commit

Permalink
Merge pull request #5 from macfarla/catch-ex
Browse files Browse the repository at this point in the history
DNS Resolver - catch for all exceptions
  • Loading branch information
macfarla authored May 9, 2024
2 parents f64cc55 + 918f70d commit 09cb122
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.tuweni.discovery
*/

import io.vertx.core.Vertx
import io.vertx.core.VertxException
import io.vertx.core.dns.DnsClient
import io.vertx.core.dns.DnsClientOptions
import io.vertx.core.dns.DnsException
Expand All @@ -31,6 +32,7 @@ import org.apache.tuweni.crypto.SECP256K1
import org.apache.tuweni.devp2p.EthereumNodeRecord
import org.slf4j.LoggerFactory
import java.io.IOException
import java.lang.Exception

/**
* Resolves a set of ENR nodes from a host name.
Expand Down Expand Up @@ -158,6 +160,13 @@ class DNSResolver @JvmOverloads constructor(
} catch (e: IOException) {
logger.warn("I/O exception contacting remote DNS server when resolving $domainName", e)
return null
} catch (e: VertxException) {
// timeouts are common
logger.warn("Vertx exception contacting remote DNS server when resolving $domainName", e)
return null
} catch (e: Exception) {
logger.warn("Exception contacting remote DNS server when resolving $domainName", e)
return null
}
}

Expand Down

0 comments on commit 09cb122

Please sign in to comment.