Skip to content

Commit

Permalink
fix: Treat HTTP endpoint timeouts as server connection exceptions (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea authored Nov 23, 2020
1 parent 125c5e3 commit f1fdd99
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import tech.relaycorp.relaynet.messages.control.PrivateNodeRegistrationRequest
import tech.relaycorp.relaynet.wrappers.x509.Certificate
import java.io.EOFException
import java.io.IOException
import java.net.SocketException
import java.net.UnknownHostException
import java.security.MessageDigest
import java.security.PublicKey
Expand Down Expand Up @@ -246,12 +245,10 @@ public class PoWebClient internal constructor(
}
body = requestBody
}
} catch (exc: SocketException) {
// Java on macOS throws a SocketException but all other platforms throw a
// ConnectException (a subclass of SocketException)
throw ServerConnectionException("Failed to connect to $url", exc)
} catch (exc: UnknownHostException) {
throw ServerConnectionException("Failed to resolve DNS for $baseURL", exc)
} catch (exc: IOException) {
throw ServerConnectionException("Failed to connect to $url", exc)
}

if (response.status.value in 200..299) {
Expand Down

0 comments on commit f1fdd99

Please sign in to comment.