Hiosdra
09/06/2020, 7:31 PM@GET("foo")
suspend fun getFoo(
@Query("param") param: String
): Either<Unit, FooDto>
and helper (ideally unnecessary) method:
fun notGonnaHappenError(): Throwable = TODO()
How to return Either<DomainError, FooDto>
?
I have this method:
private suspend fun getFoo(param: Bar): Either<DomainError, FooDto> =
Either.catch { client.getFoo(param.value).mapLeft { notGonnaHappenError() } }
.flatten()
.mapLeft { DomainError(it) }
But I think it’s not as beautiful as it can be…stojan
09/06/2020, 8:23 PMEither
stojan
09/06/2020, 8:24 PMsuspend fun getFoo(): FooDto
natively supported by retrofitstojan
09/06/2020, 8:24 PMNothing
is the correct type for "this can't happen"