After <https://github.com/Kotlin/kotlinx.serializa...
# serialization
s
After https://github.com/Kotlin/kotlinx.serialization/pull/880, what is the correct way to catch `MissingFieldException`s? Because it's now internal, doesn't have a public ancestor, and it's actually thrown when deserialization fails because of a missing field, I don't see a way (other than catching
Exception
and parsing the message, which I'd rather not) to catch this error.
v
Hi, there is no public way to do that (yet). Please follow https://github.com/Kotlin/kotlinx.serialization/issues/1266 Additionally, it would be really nice if you could tell us why it’s important to distinguish such exception from a regular SerializationException
s
Nice, thanks! And I don't mind catching a
SerializationException
(I'm actually doing that, too, as I initially thought that was the way to do it), but
MissingFieldException
is not a
SerializationException
and
MissingFieldException
is thrown specifically.
Hmm, I must be doing something wrong here, because
MissingFieldException
is indeed a
SerializationException
. 🤔
Seems to have been a build cache issue or something like that, and my
catch (SerializationException)
wasn't included in the build or something. A clean install did the trick. Thanks a bunch for pointing me in the right direction, @Vsevolod Tolstopyatov [JB]! 🙂