Error handling with effect scope and exceptions. #2879
KristianNedrevold
started this conversation in
General
Replies: 1 comment
-
Hey @KristianNedrevold, Thanks for opening this ticket! Such an API is indeed still missing. Since currently the pattern is In the 2.x.x API we have following signature, which we can back port to suspend fun <E, A> Raise<E>.catch(
block: suspend Raise<E>.() -> A,
catch: suspend Raise<E>.(Throwable) -> A
): A It's a bit more higher-level since it abstracts |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey. I'm not sure if this should be posted under discussions or issues, but as context receivers are still experimental I figured this might be the right place.
A lot of my functions that interact with APIs I don't own look like
When using EffectScope we can handle exceptions in the function call and map it to some domain error
If we want to handle it at the call site we can do something like this
Handling the exceptions at the call site is what I think is the most idiomatic solution, but it also requires exceptions to be exceptional. This is often not the case when dealing with external APIs. It would be nice if we could have a idiomatic way to catch and map exceptions to some sort of domain error type.
Maybe something like:
Beta Was this translation helpful? Give feedback.
All reactions