I folks, testing this ```either<Error, List<...
# arrow
t
I folks, testing this
Copy code
either<Error, List<String>> {
  remote.findByTerm(term)
}.mapLeft { NetworkError }
does not catch the exception, mock is configured in this way using mockito-kotlin
Copy code
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?
k
I read somewhere, but didn’t find it now.
either
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.
Copy code
either{
val result = Either.catch{ Boom() }.bind()
}
did you bind the catch?
t
I just call Either.catch instead of either block
r
The Either block is parametric to E and when in suspended form exceptions are the continuation responsibility. What could be done is give catch the binding super powers of the either block
Then Either.catch can bind either of Throwables and exit with them but disregard E, so not able to bind custom error models in the same block
👍 1
If anyone wants to work on a PR and need help I know what needs to be done. It's just adding either inside the catch block and letting the function receiver come through catch.
t
a good #hacktoberfest PR 😂