Skip to content

Commit 2ba6984

Browse files
make message of exception in decoding oneof element clearer
1 parent 2fa98b9 commit 2ba6984

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

formats/protobuf/commonMain/src/kotlinx/serialization/protobuf/internal/ProtobufDecoding.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ private class OneOfPolymorphicReader(
391391
override fun decodeTaggedString(tag: ProtoDesc): String = if (tag == POLYMORPHIC_NAME_TAG) {
392392
// todo return a serial name for polymorphic serializer
393393
descriptor.getActualOneOfSerializer(parentTag.protoId)?.serialName ?: throw SerializationException(
394-
"Cannot find a subclass of ${descriptor.serialName} in property \"${
395-
descriptor.serialName
396-
}\" annotated with @ProtoNumber(${parentTag.protoId})."
394+
"Cannot find a subclass of ${descriptor.serialName} annotated with @ProtoNumber(${parentTag.protoId})."
397395
)
398396
} else {
399397
super.decodeTaggedString(tag)

formats/protobuf/commonTest/src/kotlinx/serialization/protobuf/ProtobufOneOfTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,7 @@ class ProtobufOneOfTest {
367367

368368
@Test
369369
fun testFailWithClassDecoding() {
370-
assertFailsWith<SerializationException>(
371-
"Cannot find a subclass of kotlinx.serialization.protobuf.ProtobufOneOfTest.IFailType in property \"i\" annotated with @ProtoNumber(1)."
372-
) {
370+
assertFailsWith<SerializationException> {
373371
ProtoBuf.decodeFromHexString<FailWithClass>(
374372
"082a1a03666f6f"
375373
)

0 commit comments

Comments
 (0)