```fun fetchById(id: String?) = Either.catch(::onA...
# arrow
j
Copy code
fun 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 error
s
Inside
either { }
you can use
ensureNotNull
.
❤️ 1
There is also
leftIfNull { }
Copy code
Either.catch(::onApiError).leftIfNull { InOrderError.ApiError }
j
thanks 🙂