Skip to content

Allow IO.onError to be passed a total function #4329

@Grogs

Description

@Grogs

#4121 deprecated IO.onError(f: Throwable => IO[Unit]) and added def onError(pf: PartialFunction[Throwable, IO[Unit]]) to be used instead.

Normally total functions can be passed in place of a partial function and Scala will automatically create a partial function wrapper for it. In other words, we should be able to call the partial function variant of onError with a total function. Here's a scastie snippet showing that expected behaviour of onError with Resource.

Unfortunately, when calling IO.onError with a total function in CE 3.6.0, there is deprecation warning. This is inconsistent with earlier versions or the behaviour of ApplicativeError.onError.

It'd be great to make IO.onError not generate a deprecation warning when passed a total function.

Proposed fix from discord is to mark the deprecated version of onError as package private.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions