sealed class ResultWrapper<T> {
data class Success<T>(val data: T) : ResultWrapper<T>()
data class Unauthorized(val exception: UnauthorizedException) : ResultWrapper<Nothing>()
data class Forbidden(val exception: ForbiddenException) : ResultWrapper<Nothing>()
data class Network(val exception: NetworkException) : ResultWrapper<Nothing>()
data class NotFound(val exception: NotFoundException) : ResultWrapper<Nothing>()
data class BadRequest(val exception: BadRequestException) : ResultWrapper<Nothing>()
data class Error(val exception: Exception) : ResultWrapper<Nothing>()
}
Then I have a method that returns a
ResultWrapper<T>
but I'm only able to return the
ResultWrapper.Success(it)
how can I return the other ones?
d
Dominaezzz
10/19/2019, 3:47 PM
What happens when you try to return the other ones?
j
Joan Colmenero
10/19/2019, 4:03 PM
I solved it adding a <T> in front and changing the <Nothing> by <T>.