thanerian
10/01/2020, 7:22 PMeither<Error, List<String>> {
remote.findByTerm(term)
}.mapLeft { NetworkError }
does not catch the exception, mock is configured in this way using mockito-kotlin
given { runBlocking { remote.findByTerm(any()) } } willThrow { RuntimeException("BOOM!") }
if I use Either.catch{}
the exception is captured correctly and not propagated, is that the intended behavior?kioba
10/02/2020, 7:55 AMeither
block doesn’t catch exception and Either.catch
has to be used for something like this. assuming either{}
is equivalent of the for monadic comprehension in scala where you still have to catch an exception. so either{}
is simply for the binding, Either.catch
is for converting unpure functions to pure.kioba
10/02/2020, 7:57 AMeither{
val result = Either.catch{ Boom() }.bind()
}
did you bind the catch?thanerian
10/02/2020, 8:08 AMraulraja
10/02/2020, 9:03 AMraulraja
10/02/2020, 9:04 AMraulraja
10/02/2020, 9:11 AMthanerian
10/02/2020, 10:19 AM