Rooparsh
08/03/2020, 2:10 PM@Serializable
data class ApiError(
@SerialName("error") val error: Error
)
@Serializable
data class Error(
@SerialName("code") val code: Int,
@SerialName("timestamp") val timestamp: String,
@SerialName("path") val path: String,
@SerialName("method") val method: String,
@SerialName("message") val message: List<String>
)
And this is the parsing logic:
private fun ResponseBody?.toApiError(): ApiException {
return ApiException(
Json(
JsonConfiguration(
ignoreUnknownKeys = true,
isLenient = true
)
).parse(
ApiError.serializer(), this?.charStream()
?.readText()
.orEmpty()
)
)
}
But when I print the key message
all I get is "[User not found.]"
Am I missing here something ? I am using this dependency com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.5.0
gildor
08/03/2020, 11:44 PM