Hello! Is there a way to improve error log while r...
# ktor
r
Hello! Is there a way to improve error log while receiving data from call? If I use call.receive then if it fails error is "Failed to convert request body to class features.myMap.synchronization.request.MyMapSynchronizeRequestDTO"
Copy code
val dto = call.receive<MyMapSynchronizeRequestDTO>()
To check what is wrong I have to use standard Json deserializator from kotlinx.serialization:
Copy code
val text = call.receiveText()
val request: MyMapSynchronizeRequestDTO = Json.Default.decodeFromString(text)
Then error is very specific and I can figure out what is wrong
a
You should see the stack trace of the root cause exception like this one:
Copy code
Caused by: io.ktor.serialization.JsonConvertException: Illegal input: Unexpected JSON token at offset 2: Encountered an unknown key 'ewq' at path: $
Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.
JSON input: {"ewq": 123}
	at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:90)
	at io.ktor.server.plugins.contentnegotiation.RequestConverterKt.convertBody(RequestConverter.kt:67)
	... 94 common frames omitted