do you have an example of how you did it in `Try`?...
# arrow
p
do you have an example of how you did it in
Try
? Try and Either have the same APIs save for the constructor, which is what
Either.catch
was added for
j
initially I had
Try { }
So using the suspend-constructor
Either.catch
is actually the 'official' replacement I guess ?
and about the only one ?
btw, it is working perfectly fine, I was just wondering about other alternatives...
p
yes, the only one. You can write the old, non-suspend version for your codebase
we just don’t want to encourage it from the library
because it’s side-effecty
Copy code
fun catchE(f: () -> A): Either<Throwable, A> =
 try { f().right() } catch (t: Throwable) { t.left() }
j
ok, and then there is the infamuous
runCatching
with Result from stdlib :)
p
don’t hurt me like this hahaha
😄 1