From 1b6e854e8688047c45586f927735ae6aa8bbc7e4 Mon Sep 17 00:00:00 2001 From: Simon Vergauwen Date: Fri, 17 Mar 2023 17:35:02 +0100 Subject: [PATCH 1/2] Recommend getOrElse for handleError --- .../arrow-core/src/commonMain/kotlin/arrow/core/Either.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt index 7ed8bb779d5..cd796fde899 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt @@ -2275,14 +2275,11 @@ public inline fun Either.handleErrorWith(f: (A) -> Either) @Deprecated( RedundantAPI + "Prefer the new recover API", - ReplaceWith( - "this.recover { f(it) }", - "arrow.core.recover" - ) + ReplaceWith("getOrElse(f).right()", "arrow.core.right", "arrow.core.getOrElse") ) public inline fun Either.handleError(f: (A) -> B): Either { contract { callsInPlace(f, InvocationKind.AT_MOST_ONCE) } - return recover { a -> f(a) } + return getOrElse(f).right() } @Deprecated( From d1a902a5d98bbb7cc305074043b6ec8c85bfb9bd Mon Sep 17 00:00:00 2001 From: Simon Vergauwen Date: Fri, 17 Mar 2023 17:39:05 +0100 Subject: [PATCH 2/2] Update deprecation message --- .../core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt index cd796fde899..3733940fb55 100644 --- a/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt +++ b/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt @@ -2274,7 +2274,7 @@ public inline fun Either.handleErrorWith(f: (A) -> Either) } @Deprecated( - RedundantAPI + "Prefer the new recover API", + RedundantAPI + "Prefer resolving the error with getOrElse.", ReplaceWith("getOrElse(f).right()", "arrow.core.right", "arrow.core.getOrElse") ) public inline fun Either.handleError(f: (A) -> B): Either {