Skip to content

Commit 623dcad

Browse files
committed
Use the same message in intrinsified serializer() and reflective serializer()
1 parent 270b5e5 commit 623dcad

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

core/commonMain/src/kotlinx/serialization/Serializers.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,8 @@ private fun <T : Any> KSerializer<T>.nullable(shouldBeNullable: Boolean): KSeria
283283
*/
284284
@Suppress("unused")
285285
@PublishedApi
286-
internal fun noCompiledSerializer(forClass: String): KSerializer<*> {
287-
throw SerializationException(
288-
"Cannot find serializer for class $forClass.\n" +
289-
"Make sure that this class marked with @Serializable annotation," +
290-
"or provide serializer explicitly, or use proper SerializersModule"
291-
)
292-
}
286+
internal fun noCompiledSerializer(forClass: String): KSerializer<*> =
287+
throw SerializationException(notRegisteredMessage(forClass))
293288

294289
// Used when compiler intrinsic is inserted
295290
@OptIn(ExperimentalSerializationApi::class)

core/commonMain/src/kotlinx/serialization/internal/Platform.common.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ internal fun KClass<*>.serializerNotRegistered(): Nothing {
9292
throw SerializationException(notRegisteredMessage())
9393
}
9494

95-
internal fun KClass<*>.notRegisteredMessage(): String = "Serializer for class '${simpleName}' is not found.\n" +
96-
"Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied."
95+
internal fun KClass<*>.notRegisteredMessage(): String = notRegisteredMessage(simpleName ?: "<local class name not available>")
96+
97+
internal fun notRegisteredMessage(className: String): String = "Serializer for class '$className' is not found.\n" +
98+
"Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.\n"
9799

98100
internal expect fun KClass<*>.platformSpecificSerializerNotRegistered(): Nothing
99101

0 commit comments

Comments
 (0)