Merge remote-tracking branch 'origin/master'

This commit is contained in:
Hosted Weblate
2025-01-22 00:18:37 +01:00
2 changed files with 10 additions and 1 deletions

View File

@ -23,7 +23,7 @@ import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.math.absoluteValue
/** Api has not yet been published to stable, and will cause MethodNotFoundException on stable */
/** Api has not yet been published to stable, and will cause `NoSuchMethodException` on stable */
@MustBeDocumented // Same as java.lang.annotation.Documented
@Retention(AnnotationRetention.SOURCE) // This is only an IDE hint, and will not be used in the runtime
annotation class Prerelease

View File

@ -10,6 +10,7 @@ import java.net.UnknownHostException
import javax.net.ssl.SSLHandshakeException
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.reflect.full.NoSuchPropertyException
const val DEBUG_EXCEPTION = "THIS IS A DEBUG EXCEPTION!"
const val DEBUG_PRINT = "DEBUG PRINT"
@ -122,6 +123,14 @@ fun<T> throwAbleToResource(
throwable: Throwable
): Resource<T> {
return when (throwable) {
is NoSuchMethodException, is NoSuchFieldException, is NoSuchMethodError, is NoSuchFieldError, is NoSuchPropertyException -> {
Resource.Failure(
false,
null,
null,
"App or extension is outdated, update the app or try pre-release.\n${throwable.message}" // todo add exact version?
)
}
is NullPointerException -> {
for (line in throwable.stackTrace) {
if (line?.fileName?.endsWith("provider.kt", ignoreCase = true) == true) {