Skip to content

Commit b0b60c1

Browse files
committed
Change descriptor to INT for correct serialization
1 parent 7d2e993 commit b0b60c1

File tree

1 file changed

+4
-4
lines changed
  • src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk

1 file changed

+4
-4
lines changed

src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.util.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ private val logger = KotlinLogging.logger {}
1717

1818
internal object ErrorCodeSerializer : KSerializer<ErrorCode> {
1919
override val descriptor: SerialDescriptor =
20-
PrimitiveSerialDescriptor("io.modelcontextprotocol.kotlin.sdk.ErrorCode", PrimitiveKind.STRING)
20+
PrimitiveSerialDescriptor("io.modelcontextprotocol.kotlin.sdk.ErrorCode", PrimitiveKind.INT)
2121

2222
@OptIn(ExperimentalSerializationApi::class)
2323
override fun serialize(encoder: Encoder, value: ErrorCode) {
2424
encoder.encodeInt(value.code)
2525
}
2626

2727
override fun deserialize(decoder: Decoder): ErrorCode {
28-
val decodedString = decoder.decodeInt()
29-
return ErrorCode.Defined.entries.firstOrNull { it.code == decodedString }
30-
?: ErrorCode.Unknown(decodedString)
28+
val decodedInt = decoder.decodeInt()
29+
return ErrorCode.Defined.entries.firstOrNull { it.code == decodedInt }
30+
?: ErrorCode.Unknown(decodedInt)
3131
}
3232
}
3333

0 commit comments

Comments
 (0)