I have this custom exception class ```@Serializabl...
# stdlib
v
I have this custom exception class
Copy code
@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?
I'm using KotlinX Serialization to map ktor's api error response to this exception
Copy code
json.decodeFromString<MyException>(errorResponse.bodyAsText())