maskipli
06/27/2021, 4:46 AMsealed 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>()
}
edenman
06/27/2021, 6:46 AMclient.request(builder).body<String>()
and then do the parsing myself to decide if i should return Success
catch (e: ResponseException)
for Error
catch: e: Throwable
for Failure
)maskipli
06/29/2021, 3:22 AM