From fee6dd7bde62aa4c05651c946f039dbff266da28 Mon Sep 17 00:00:00 2001 From: Kolchurin Konstantin Date: Tue, 10 Feb 2026 17:10:35 +0700 Subject: [PATCH 1/6] #224 updated kotlin, moko-resources --- gradle.properties | 2 ++ gradle/libs.versions.toml | 6 +++--- network-bignum/build.gradle.kts | 4 ++++ network-engine/build.gradle.kts | 4 ++++ network-errors/build.gradle.kts | 6 ++++++ network/build.gradle.kts | 4 ++++ sample/mpp-library/build.gradle.kts | 4 ++-- 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 39823b5..3e8b516 100755 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,8 @@ kotlin.mpp.applyDefaultHierarchyTemplate=false android.useAndroidX=true mobile.multiplatform.iosTargetWarning=false +mobile.multiplatform.useIosShortcut=false +moko.resources.disableStaticFrameworkWarning=true xcodeproj=./sample/ios-app diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc64c93..eb1d3e5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlinVersion = "2.0.20" +kotlinVersion = "2.1.0" # android lifecycleViewModelVersion = "2.6.1" @@ -16,11 +16,11 @@ kotlinxSerializationVersion = "1.7.3" coroutinesVersion = "1.9.0" # moko -mokoResourcesVersion = "0.24.4" +mokoResourcesVersion = "0.26.0" mokoMvvmVersion = "0.16.0" mokoErrorsVersion = "0.7.0" mokoTestVersion = "0.6.1" -mokoNetworkVersion = "0.22.0" +mokoNetworkVersion = "0.23.0" # tests espressoCoreVersion = "3.5.1" diff --git a/network-bignum/build.gradle.kts b/network-bignum/build.gradle.kts index edf3dba..6e7909f 100644 --- a/network-bignum/build.gradle.kts +++ b/network-bignum/build.gradle.kts @@ -15,6 +15,10 @@ android { kotlin { jvm() + + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } } dependencies { diff --git a/network-engine/build.gradle.kts b/network-engine/build.gradle.kts index d9fbf26..1057abe 100644 --- a/network-engine/build.gradle.kts +++ b/network-engine/build.gradle.kts @@ -35,6 +35,10 @@ kotlin { dependsOn(commonJvmAndroid) } } + + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } } dependencies { diff --git a/network-errors/build.gradle.kts b/network-errors/build.gradle.kts index 5c408fe..0947911 100644 --- a/network-errors/build.gradle.kts +++ b/network-errors/build.gradle.kts @@ -14,6 +14,12 @@ android { namespace = "dev.icerock.moko.network.errors" } +kotlin { + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } +} + dependencies { commonMainImplementation(libs.kotlinSerialization) diff --git a/network/build.gradle.kts b/network/build.gradle.kts index d9dc954..b841bba 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -39,6 +39,10 @@ kotlin { } } } + + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } } dependencies { diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 5a6578f..f3013ce 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -10,10 +10,10 @@ plugins { id("dev.icerock.moko.gradle.android.base") id("org.jetbrains.kotlin.multiplatform") id("org.jetbrains.kotlin.plugin.serialization") - id("dev.icerock.mobile.multiplatform.targets") + id("dev.icerock.moko.gradle.multiplatform.mobile") + id("dev.icerock.mobile.multiplatform.ios-framework") id("dev.icerock.mobile.multiplatform-resources") id("dev.icerock.mobile.multiplatform-network-generator") - id("dev.icerock.mobile.multiplatform.ios-framework") id("dev.icerock.moko.gradle.detekt") id("dev.icerock.moko.gradle.tests") } From c8c3ba8d698dc98d28dd81f2a21f7c5e43bd766e Mon Sep 17 00:00:00 2001 From: Kolchurin Konstantin Date: Tue, 10 Feb 2026 17:26:44 +0700 Subject: [PATCH 2/6] #224 added default error text --- .../icerock/moko/network/errors/NetworkErrorsTexts.kt | 2 ++ .../moko/network/errors/NetworkExceptionMappers.kt | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt index c63e01f..813b0b0 100644 --- a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt +++ b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt @@ -4,9 +4,11 @@ package dev.icerock.moko.network.errors +import dev.icerock.moko.errors.MR as ErrorsMR import dev.icerock.moko.resources.StringResource data class NetworkErrorsTexts( + val defaultErrorText: StringResource = ErrorsMR.strings.moko_errors_unknownError, val networkConnectionErrorText: StringResource = MR.strings.networkConnectionErrorText, val serializationErrorText: StringResource = MR.strings.serializationErrorText, val httpNetworkErrorsTexts: HttpNetworkErrorsTexts = HttpNetworkErrorsTexts(), diff --git a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt index 83cc0cb..3ca3712 100644 --- a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt +++ b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt @@ -12,6 +12,7 @@ import dev.icerock.moko.network.exceptions.ValidationException import dev.icerock.moko.network.getSSLExceptionType import dev.icerock.moko.network.isNetworkConnectionError import dev.icerock.moko.network.isSSLException +import dev.icerock.moko.resources.StringResource import dev.icerock.moko.resources.desc.CompositionStringDesc import dev.icerock.moko.resources.desc.ResourceFormatted import dev.icerock.moko.resources.desc.StringDesc @@ -36,6 +37,7 @@ fun ExceptionMappersStorage.registerAllNetworkMappers( mapper = { getSSLExceptionStringDescMapper( sslException = it, + defaultErrorText = errorsTexts.defaultErrorText, sslNetworkErrorsTexts = errorsTexts.sslNetworkErrorsTexts ) } @@ -45,6 +47,7 @@ fun ExceptionMappersStorage.registerAllNetworkMappers( ).register { getNetworkErrorExceptionStringDescMapper( errorException = it, + defaultErrorText = errorsTexts.defaultErrorText, httpNetworkErrorsTexts = errorsTexts.httpNetworkErrorsTexts ) }.register(::validationExceptionStringDescMapper) @@ -55,6 +58,7 @@ fun ExceptionMappersStorage.registerAllNetworkMappers( */ private fun getNetworkErrorExceptionStringDescMapper( errorException: ErrorException, + defaultErrorText: StringResource, httpNetworkErrorsTexts: HttpNetworkErrorsTexts ): StringDesc { val httpStatusCode = errorException.httpStatusCode @@ -69,7 +73,7 @@ private fun getNetworkErrorExceptionStringDescMapper( ) } - else -> MR.strings.moko_errors_unknownError.desc() + else -> defaultErrorText.desc() } } @@ -79,6 +83,7 @@ private fun getNetworkErrorExceptionStringDescMapper( @Suppress("ComplexMethod") private fun getSSLExceptionStringDescMapper( sslException: Throwable, + defaultErrorText: StringResource, sslNetworkErrorsTexts: SSLNetworkErrorsTexts ): StringDesc { return when (sslException.getSSLExceptionType()) { @@ -90,7 +95,7 @@ private fun getSSLExceptionStringDescMapper( SSLExceptionType.ClientCertificateRejected -> sslNetworkErrorsTexts.clientCertificateRejected.desc() SSLExceptionType.ClientCertificateRequired -> sslNetworkErrorsTexts.clientCertificateRequired.desc() SSLExceptionType.CannotLoadFromNetwork -> sslNetworkErrorsTexts.cannotLoadFromNetwork.desc() - else -> MR.strings.moko_errors_unknownError.desc() + else -> defaultErrorText.desc() } } From 2ea199dee3df52c6c923a5300a1d8b5be8c82974 Mon Sep 17 00:00:00 2001 From: Kolchurin Konstantin Date: Tue, 10 Feb 2026 18:06:48 +0700 Subject: [PATCH 3/6] #224 moko-errors 0.9.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index eb1d3e5..ae0a69a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,7 +18,7 @@ coroutinesVersion = "1.9.0" # moko mokoResourcesVersion = "0.26.0" mokoMvvmVersion = "0.16.0" -mokoErrorsVersion = "0.7.0" +mokoErrorsVersion = "0.9.0" mokoTestVersion = "0.6.1" mokoNetworkVersion = "0.23.0" From 13e30a8507f0219f62b5714886310438138bee4e Mon Sep 17 00:00:00 2001 From: Kolchurin Konstantin Date: Tue, 10 Feb 2026 18:14:41 +0700 Subject: [PATCH 4/6] #224 reformat --- .../dev/icerock/moko/network/errors/NetworkErrorsTexts.kt | 2 +- .../dev/icerock/moko/network/errors/NetworkExceptionMappers.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt index 813b0b0..6599a55 100644 --- a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt +++ b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt @@ -4,8 +4,8 @@ package dev.icerock.moko.network.errors -import dev.icerock.moko.errors.MR as ErrorsMR import dev.icerock.moko.resources.StringResource +import dev.icerock.moko.errors.MR as ErrorsMR data class NetworkErrorsTexts( val defaultErrorText: StringResource = ErrorsMR.strings.moko_errors_unknownError, diff --git a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt index 3ca3712..ff03ada 100644 --- a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt +++ b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkExceptionMappers.kt @@ -4,7 +4,6 @@ package dev.icerock.moko.network.errors -import dev.icerock.moko.errors.MR import dev.icerock.moko.errors.mappers.ExceptionMappersStorage import dev.icerock.moko.network.SSLExceptionType import dev.icerock.moko.network.exceptions.ErrorException From 4cdfc43d2a4584025d74fad2bca58ff25b14cc6c Mon Sep 17 00:00:00 2001 From: Kolchurin Konstantin Date: Fri, 13 Feb 2026 15:45:47 +0700 Subject: [PATCH 5/6] #224 updated version in readme, added customization of error texts --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3e977f9..1fcafb9 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ buildscript { } dependencies { - classpath "dev.icerock.moko:network-generator:0.22.0" + classpath "dev.icerock.moko:network-generator:0.23.0" } } @@ -53,10 +53,10 @@ project build.gradle apply plugin: "dev.icerock.mobile.multiplatform-network-generator" dependencies { - commonMainApi("dev.icerock.moko:network:0.22.0") - commonMainApi("dev.icerock.moko:network-engine:0.22.0") // configured HttpClientEngine - commonMainApi("dev.icerock.moko:network-bignum:0.22.0") // kbignum serializer - commonMainApi("dev.icerock.moko:network-errors:0.22.0") // moko-errors integration + commonMainApi("dev.icerock.moko:network:0.23.0") + commonMainApi("dev.icerock.moko:network-engine:0.23.0") // configured HttpClientEngine + commonMainApi("dev.icerock.moko:network-bignum:0.23.0") // kbignum serializer + commonMainApi("dev.icerock.moko:network-errors:0.23.0") // moko-errors integration } ``` @@ -175,6 +175,52 @@ viewModelScope.launch { } ``` +#### Customizing error texts + +You can override standard error messages (which are localized in English and Russian by default) by +passing your own NetworkErrorsTexts object. This allows you to customize messages for HTTP errors, +SSL issues, serialization failures, and set a fallback defaultErrorText. + +Usage example: + +```kotlin +// 1. Define HTTP specific errors +private val httpNetworkErrorsTexts = HttpNetworkErrorsTexts( + unauthorizedErrorText = MR.strings.unauthorizedErrorText, + notFoundErrorText = MR.strings.notFoundErrorText, + accessDeniedErrorText = MR.strings.accessDeniedErrorText, + internalServerErrorText = MR.strings.internalServerErrorText +) + +// 2. Define SSL specific errors +private val sslNetworkErrorsTexts = SSLNetworkErrorsTexts( + secureConnectionFailed = MR.strings.secureConnectionFailedText, + serverCertificateHasBadDate = MR.strings.serverCertificateHasBadDateText, + serverCertificateUntrusted = MR.strings.serverCertificateUntrustedText, + serverCertificateHasUnknownRoot = MR.strings.serverCertificateHasUnknownRootText, + serverCertificateNotYetValid = MR.strings.serverCertificateNotYetValidText, + clientCertificateRejected = MR.strings.clientCertificateRejectedText, + clientCertificateRequired = MR.strings.clientCertificateRequiredText, + cannotLoadFromNetwork = MR.strings.cannotLoadFromNetworkText +) + +// 3. Assemble all texts including general network errors and default fallback +private val networkErrorsTexts = NetworkErrorsTexts( + networkConnectionErrorText = MR.strings.networkConnectionErrorText, + serializationErrorText = MR.strings.serializationErrorText, + httpNetworkErrorsTexts = httpNetworkErrorsTexts, + sslNetworkErrorsTexts = sslNetworkErrorsTexts, + defaultErrorText = MR.strings.defaultErrorText // Fallback for undefined errors +) + +// 4. Register mappers with your custom texts +fun initExceptionMappersStorage() { + ExceptionMappersStorage.registerAllNetworkMappers( + errorsTexts = networkErrorsTexts + ) +} +``` + For more information about exception handling see [moko-errors](https://github.com/icerockdev/moko-errors). ## Samples From 149a323f92c80bfd0c7ef879263e1d1c82135bfa Mon Sep 17 00:00:00 2001 From: Kolchurin Konstantin Date: Fri, 13 Feb 2026 15:46:03 +0700 Subject: [PATCH 6/6] #224 changed fields ordering --- .../dev/icerock/moko/network/errors/NetworkErrorsTexts.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt index 6599a55..5af91c9 100644 --- a/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt +++ b/network-errors/src/commonMain/kotlin/dev/icerock/moko/network/errors/NetworkErrorsTexts.kt @@ -8,11 +8,11 @@ import dev.icerock.moko.resources.StringResource import dev.icerock.moko.errors.MR as ErrorsMR data class NetworkErrorsTexts( - val defaultErrorText: StringResource = ErrorsMR.strings.moko_errors_unknownError, val networkConnectionErrorText: StringResource = MR.strings.networkConnectionErrorText, val serializationErrorText: StringResource = MR.strings.serializationErrorText, val httpNetworkErrorsTexts: HttpNetworkErrorsTexts = HttpNetworkErrorsTexts(), - val sslNetworkErrorsTexts: SSLNetworkErrorsTexts = SSLNetworkErrorsTexts() + val sslNetworkErrorsTexts: SSLNetworkErrorsTexts = SSLNetworkErrorsTexts(), + val defaultErrorText: StringResource = ErrorsMR.strings.moko_errors_unknownError, ) data class HttpNetworkErrorsTexts(