I want to detect situation in which server returne...
# serialization
a
I want to detect situation in which server returned a 200 OK response, but there was a problem on client side with reading the response I hoped to use
kotlinx.serialization.json.internal.JsonDecodingException
but it is an internal API so I have to use reflection is there any better way to do this?
s
Would it work if you catch the super class
SerializationException
?
a
that's probably actually better 🤔 thanks for pointing it out https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-serialization-exception/
For general "catch-all" patterns around deserialization of potentially untrusted/invalid/corrupted data it is recommended to catch
IllegalArgumentException
type
they even say I might want to go one step further