jean
11/26/2021, 7:52 AMfun fetchById(id: String?) = Either.catch(::onApiError) {
id ?: return Either.Left(InOrderError.ApiError)
...
}
is there an nicer way to guard the nullability of Id in this case? I found left() but it doesn’t let me pass a type of errorsimon.vergauwen
11/26/2021, 8:30 AMeither { } you can use ensureNotNull.simon.vergauwen
11/26/2021, 8:30 AMleftIfNull { }simon.vergauwen
11/26/2021, 8:31 AMEither.catch(::onApiError).leftIfNull { InOrderError.ApiError }jean
11/26/2021, 9:24 AM