Vaibhav Jaiswal
09/17/2024, 8:52 AM@Serializable
class MyApiException(
val errors: List<MyApiError>
) : Exception(errors.firstOrNull()?.clientMessage)
@Serializable
data class MyApiError(
val clientMessage: String
)
But this is not working as expected, even though the errors
list is non empty the exception.message
field is null
I tried debugging and the errors.firstOrNull()?.clientMessage
results perfectly, still message
is null
Any idea why?Vaibhav Jaiswal
09/17/2024, 8:53 AMVaibhav Jaiswal
09/17/2024, 8:59 AMjson.decodeFromString<MyException>(errorResponse.bodyAsText())