Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/src/main/java/app/grapheneos/apps/core/Errors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ private fun networkErrorResStringOrZero(e: Throwable) = when (e) {
else -> 0
}

private fun isKnownNetworkError(e: Throwable) = when (e) {
is ConnectException,
is SocketTimeoutException,
is UnknownHostException -> true
else -> false
}

@Parcelize
class RepoUpdateError(val throwable: Throwable, val wasUpdateManuallyRequested: Boolean) : ErrorTemplate() {
override fun titleResource() = if (wasUpdateManuallyRequested)
Expand All @@ -122,8 +129,10 @@ class RepoUpdateError(val throwable: Throwable, val wasUpdateManuallyRequested:
appendRes(ctx, resource)
append('.')
}
appendDetailsPrefix(ctx, this)
append(throwable.toString())
if (!isKnownNetworkError(throwable)) {
appendDetailsPrefix(ctx, this)
append(throwable.toString())
}
toString()
}
}
Expand Down Expand Up @@ -159,7 +168,8 @@ class DownloadError(val pkgLabels: List<String>, val throwable: Throwable) : Err
}
append('.')

if (throwable !is UserRestrictionException && throwable !is PackagesBusyException) {
if (throwable !is UserRestrictionException && throwable !is PackagesBusyException
&& !isKnownNetworkError(throwable)) {
appendDetailsPrefix(ctx, this)
append(throwable.toString())
}
Expand Down