I was reading over the changes in <https://github....
# arrow
a
I was reading over the changes in https://github.com/arrow-kt/arrow-fx/pull/169 and was curious what the approach for error handling would be. Is the general approach to use something like this at any boundaries to exceptional libraries:
Copy code
suspend fun load(): Either<DomainError, DomainResult> = effectCatch(::errorHandler) {
    loadDomain()
}
I had used IO and used handleErrorWith to translate errors at my applications boundaries, but perhaps this is cleaner to mostly remove exceptions from my domain?
s
Yes, it's always cleaner to remove exceptions from your domain. That's why many people combine
Either
with
IO
in FP, but that can be a bit annoying since you have nesting or need to use monad transformers which come with other complexities. Replacing
IO
with
suspend
you can use
Either
in a cleaner and more Kotlin idiomatic way and Arrow Fx Coroutines offers the same API as
IO
in terms of concurrency. You'll find everything from
parMapN
to racing and
parTraverse
and all the same data types.
At the edge you can still use
Either.catch { }.handleErrorWith
like you did with
IO
.
a
alright, that's about what I had in mind. I had been using sealed classes that extended throwable and "normalizing" any exceptions to my domain model with IO to get around the nesting issues. So this will likely be much cleaner. Thank you!
👍 1