Tower Guidev2
03/01/2022, 1:45 PMval work: Either<DatasourceException, *> = either { persistOutcome().bind() }
raulraja
03/01/2022, 1:51 PMval work = persistOutcome()
simon.vergauwen
03/01/2022, 1:51 PMeither { }
with a single bind()
is redundant and equivalent to persistentOutcome()
.
If you're trying to capture any unexpected exceptions you should use Either.catch
and mapLeft
to map Throwable
to your error domain.Tower Guidev2
03/01/2022, 1:52 PMYoussef Shoaib [MOD]
03/01/2022, 4:09 PMpersistentOutcome().flatMap { Either.Right(it) }
and so you're turning a Right result into a Right result of the same exact value and a Left result into itself, and so in both cases it's just a more-convoluted identity