Skip to content

Commit

Permalink
Use the same message in intrinsified serializer() and reflective seri…
Browse files Browse the repository at this point in the history
…alizer()
  • Loading branch information
sandwwraith committed Feb 7, 2023
1 parent 270b5e5 commit 623dcad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 2 additions & 7 deletions core/commonMain/src/kotlinx/serialization/Serializers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 623dcad

Please sign in to comment.