Fixed network restoration

commit_hash:3cf163db68f76561800ac8e530e435a09f625e62
This commit is contained in:
burstein
2026-05-06 11:36:06 +03:00
parent 2f7188a724
commit 5dbf96c702
2 changed files with 6 additions and 23 deletions
@@ -38,10 +38,8 @@ private fun Throwable?.isNetworkConnectivityError(): Boolean {
is ConnectException,
is SocketTimeoutException,
is SocketException,
is InterruptedIOException -> return true
is HttpException -> {
if (cause.response.code == 408 || cause.response.code == 504) return true
}
is InterruptedIOException,
is HttpException -> return true
}
cause = cause.cause
}
@@ -68,23 +68,8 @@ class ImageNetworkRestorationTest {
}
@Test
fun `restarts on HTTP 504`() = expectRestart {
httpErrorResult(it, code = 504)
}
@Test
fun `restarts on HTTP 408`() = expectRestart {
httpErrorResult(it, code = 408)
}
@Test
fun `does not restart on HTTP 500`() = expectNoRestart {
httpErrorResult(it, code = 500)
}
@Test
fun `does not restart on HTTP 404`() = expectNoRestart {
httpErrorResult(it, code = 404)
fun `restarts on HTTP error result`() = expectRestart {
httpErrorResult(it)
}
@Test
@@ -201,10 +186,10 @@ class ImageNetworkRestorationTest {
throwable = UnknownHostException("offline"),
)
private fun httpErrorResult(request: ImageRequest, code: Int): ErrorResult =
private fun httpErrorResult(request: ImageRequest): ErrorResult =
ErrorResult(
image = null,
request = request,
throwable = HttpException(NetworkResponse().copy(code = code)),
throwable = HttpException(NetworkResponse()),
)
}