Hey, I'm having some trouble with kotlinx.serializ...
# ktor
e
Hey, I'm having some trouble with kotlinx.serialization, I defined a class to deserialize a request, annotated it with Serializable and then from inside a route I'm calling call.receiveOrNull<MyRequest>() But insted of null I'm getting an exception when the request is bad formed. Is this the expected behavior? And if yes what's the point of receiveOrNull?
I was also trying to handle exceptions, but it seems like kotlinx.serialization exceptions are internal, so I can only catch Exception? Is there some way to differentiate between the errors?
a
Here you can find an explanation about the
receiveOrNull
behavior logic. There is the SerializationException that is the only public exception class. Unfortunately, there is no way to differentiate kotlinx.serialization library errors.
e
hey, thanks for the answer! I don't know enough about networking to think about an example for negotiation failing... anyway, am I doing it right? Do I have to catch exceptions in order to handle the bad requests?
b
który client json array