Joan Colmenero
10/19/2019, 3:42 PMsealed class
?
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?Dominaezzz
10/19/2019, 3:47 PMJoan Colmenero
10/19/2019, 4:03 PMKroppeb
10/19/2019, 4:04 PMsealed class ResultWrapper<out T>
should have worked fine too.Joan Colmenero
10/19/2019, 4:20 PM