hey folks. how to mapping result from Ktor request...
# ktor
m
hey folks. how to mapping result from Ktor request into sealed class like bellow
Copy code
sealed class NetworkResponse<out S : Any, out E : Any> {

    data class Success<S : Any>(
        val body: S,
        val code: Int
    ) : NetworkResponse<S, Nothing>()

    data class Error<E : Any>(
        val errorBody: E,
        val code: Int
    ) : NetworkResponse<Nothing, E>()

    data class Failure(val error: Exception) : NetworkResponse<Nothing, Nothing>()

}
e
I just do
client.request(builder).body<String>()
and then do the parsing myself to decide if i should return
Success
and then
catch (e: ResponseException)
for
Error
(and
catch: e: Throwable
for
Failure
)
m
thanks @edenman
👍🏾 1