Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend Either.getOrElse for handleError instead of recover #2986

Merged
merged 3 commits into from
Mar 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2274,15 +2274,12 @@ public inline fun <A, B, C> Either<A, B>.handleErrorWith(f: (A) -> Either<C, B>)
}

@Deprecated(
RedundantAPI + "Prefer the new recover API",
ReplaceWith(
"this.recover<A, Nothing, B> { f(it) }",
"arrow.core.recover"
)
RedundantAPI + "Prefer resolving the error with getOrElse.",
ReplaceWith("getOrElse(f).right()", "arrow.core.right", "arrow.core.getOrElse")
)
public inline fun <A, B> Either<A, B>.handleError(f: (A) -> B): Either<A, B> {
contract { callsInPlace(f, InvocationKind.AT_MOST_ONCE) }
return recover { a -> f(a) }
return getOrElse(f).right()
}

@Deprecated(
Expand Down