Skip to content

Commit

Permalink
Deprecate ResourceMonadError
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Sep 5, 2024
1 parent 3c2d6af commit cb1a293
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1349,10 +1349,19 @@ abstract private[effect] class ResourceFOInstances1 {
}

abstract private[effect] class ResourceMonadCancel[F[_]]
extends ResourceMonadError[F, Throwable]
extends ResourceMonad[F]
with MonadCancel[Resource[F, *], Throwable] {
implicit protected def F: MonadCancel[F, Throwable]

override def attempt[A](fa: Resource[F, A]): Resource[F, Either[Throwable, A]] =
fa.attempt(F)

def handleErrorWith[A](fa: Resource[F, A])(f: Throwable => Resource[F, A]): Resource[F, A] =
fa.handleErrorWith(f)

def raiseError[A](e: Throwable): Resource[F, A] =
Resource.raiseError[F, A, Throwable](e)

def canceled: Resource[F, Unit] = Resource.canceled

def forceR[A, B](fa: Resource[F, A])(fb: Resource[F, B]): Resource[F, B] =
Expand Down Expand Up @@ -1474,6 +1483,7 @@ abstract private[effect] class ResourceAsync[F[_]]
Resource.executionContext
}

@deprecated("Use ResourceMonadCancel", "3.6.0")
abstract private[effect] class ResourceMonadError[F[_], E]
extends ResourceMonad[F]
with MonadError[Resource[F, *], E] {
Expand All @@ -1484,7 +1494,7 @@ abstract private[effect] class ResourceMonadError[F[_], E]
fa.attempt(F)

def handleErrorWith[A](fa: Resource[F, A])(f: E => Resource[F, A]): Resource[F, A] =
fa.handleErrorWith(f)
fa.handleErrorWith(f)(F)

def raiseError[A](e: E): Resource[F, A] =
Resource.raiseError[F, A, E](e)
Expand Down

0 comments on commit cb1a293

Please sign in to comment.