diff options
author | Leonid Startsev <sandwwraith@gmail.com> | 2023-01-30 16:29:47 +0100 |
---|---|---|
committer | Leonid Startsev <sandwwraith@users.noreply.github.com> | 2023-02-07 13:20:44 +0100 |
commit | 623dcad3761e7b6634e4144deaef283cab58f490 (patch) | |
tree | 0823441cf2e05e2dcffad78c0aac02b6d75a1981 /core | |
parent | 270b5e546e57fcfcc894c63e2e8af4fc338c0bff (diff) | |
download | kotlinx.serialization-623dcad3761e7b6634e4144deaef283cab58f490.tar.gz |
Use the same message in intrinsified serializer() and reflective serializer()
Diffstat (limited to 'core')
-rw-r--r-- | core/commonMain/src/kotlinx/serialization/Serializers.kt | 9 | ||||
-rw-r--r-- | core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt | 6 |
2 files changed, 6 insertions, 9 deletions
diff --git a/core/commonMain/src/kotlinx/serialization/Serializers.kt b/core/commonMain/src/kotlinx/serialization/Serializers.kt index 01ea4507..fb34224e 100644 --- a/core/commonMain/src/kotlinx/serialization/Serializers.kt +++ b/core/commonMain/src/kotlinx/serialization/Serializers.kt @@ -283,13 +283,8 @@ private fun <T : Any> KSerializer<T>.nullable(shouldBeNullable: Boolean): KSeria */ @Suppress("unused") @PublishedApi -internal fun noCompiledSerializer(forClass: String): KSerializer<*> { - throw SerializationException( - "Cannot find serializer for class $forClass.\n" + - "Make sure that this class marked with @Serializable annotation," + - "or provide serializer explicitly, or use proper SerializersModule" - ) -} +internal fun noCompiledSerializer(forClass: String): KSerializer<*> = + throw SerializationException(notRegisteredMessage(forClass)) // Used when compiler intrinsic is inserted @OptIn(ExperimentalSerializationApi::class) diff --git a/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt b/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt index f5b8e83b..e9351853 100644 --- a/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt +++ b/core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt @@ -92,8 +92,10 @@ internal fun KClass<*>.serializerNotRegistered(): Nothing { throw SerializationException(notRegisteredMessage()) } -internal fun KClass<*>.notRegisteredMessage(): String = "Serializer for class '${simpleName}' is not found.\n" + - "Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied." +internal fun KClass<*>.notRegisteredMessage(): String = notRegisteredMessage(simpleName ?: "<local class name not available>") + +internal fun notRegisteredMessage(className: String): String = "Serializer for class '$className' is not found.\n" + + "Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.\n" internal expect fun KClass<*>.platformSpecificSerializerNotRegistered(): Nothing |