Closed Jasper-M closed 2 months ago
I think we can fix this one fairly source-compatibly.
Hey @armanbilge @Jasper-M I'd love to take this on, if you'd assign it to me.
Assigned!
@armanbilge I'd like to take on this one. As I mentioned in discord, I believe We can implement the onError
function like this:
def onError(pf: PartialFunction[Throwable, IO[Unit]]): IO[A] =
// ~~handleErrorWith(t => pf.applyOrElse(t, IO.raiseError[A]) *> IO.raiseError(t))~~
handleErrorWith(t => pf.applyOrElse(t, (_: Throwable) => IO.unit) *> IO.raiseError(t))
But I'm not very familiar with source compatible thingy, could you provide some pointer for me?
@lenguyenthanh great, open up a PR!
But I'm not very familiar with source compatible thingy, could you provide some pointer for me?
By source-compatible, what I mean is that we don't break compilation of existing code that's using the old, inconsistent method definition. I think if we add this additional definition and deprecate the old one, it will be okay.
The
onError
that you get fromApplicativeError
has this signature:While the "native" one in
IO
doesn't take aPartialFunction
:That could lead to some surprises if you would rewrite a piece of code from tagless final to
IO
, or if you are just used to using theonError
extension method in other code.