Skip to content

Commit

Permalink
fix(Parcel delivery): Handle SocketException
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea committed Sep 7, 2020
1 parent e9113f6 commit c713c7e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import tech.relaycorp.relaynet.wrappers.x509.Certificate
import java.io.Closeable
import java.io.EOFException
import java.net.ConnectException
import java.net.SocketException

/**
* PoWeb client.
Expand Down Expand Up @@ -77,7 +78,9 @@ public class PoWebClient internal constructor(
ktorClient.post<Unit>("$baseURL/parcels") {
body = ByteArrayContent(parcelSerialized, PARCEL_CONTENT_TYPE)
}
} catch (exc: ConnectException) {
} 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 $baseURL", exc)
} catch (exc: ResponseException) {
val status = exc.response!!.status
Expand Down

0 comments on commit c713c7e

Please sign in to comment.