1package soy.iko.opencode.data.repo
3import io.ktor.client.plugins.HttpRequestTimeoutException
4import io.ktor.client.request.HttpRequestBuilder
5import org.junit.Assert.assertEquals
7import java.io.IOException
8import java.net.ConnectException
9import java.net.SocketTimeoutException
10import java.net.UnknownHostException
15 fun unknownHostIsNotReachable() {
16 assertEquals(ErrorKind.NOT_REACHABLE, classifyError(UnknownHostException("nope")))
20 fun connectRefusedIsNotReachable() {
21 assertEquals(ErrorKind.NOT_REACHABLE, classifyError(ConnectException("refused")))
25 fun socketTimeoutIsTimeout() {
26 assertEquals(ErrorKind.TIMEOUT, classifyError(SocketTimeoutException("read timed out")))
30 fun httpRequestTimeoutIsTimeout() {
31 assertEquals(ErrorKind.TIMEOUT, classifyError(HttpRequestTimeoutException(HttpRequestBuilder())))
35 fun genericIoIsNetwork() {
36 assertEquals(ErrorKind.NETWORK, classifyError(IOException("broken pipe")))
40 fun unrelatedThrowableIsUnknown() {
41 assertEquals(ErrorKind.UNKNOWN, classifyError(IllegalStateException("boom")))
45 fun unwrapsCauseChainToClassifyRoot() {
46 // A library may surface a network failure wrapped in a non-IO exception.
47 val wrapped = RuntimeException("request failed", UnknownHostException("nested"))
48 assertEquals(ErrorKind.NOT_REACHABLE, classifyError(wrapped))
52 fun doesNotLoopInfinitelyOnCyclicCause() {
53 // A self-referential cause chain must be terminated by the bounded hop count,
54 // not followed into a stack overflow.
55 val cyclic: Throwable = object : Throwable("cyclic") {
56 override val cause: Throwable? get() = this
58 assertEquals(ErrorKind.UNKNOWN, classifyError(cyclic))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list