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

Avoid using NonFatal.unapply #4282

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/ApplicativeError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ trait ApplicativeError[F[_], E] extends Applicative[F] {
def catchNonFatal[A](a: => A)(implicit ev: Throwable <:< E): F[A] =
try pure(a)
catch {
case NonFatal(e) => raiseError(e)
case e if NonFatal(e) => raiseError(e)
}

/**
Expand All @@ -257,7 +257,7 @@ trait ApplicativeError[F[_], E] extends Applicative[F] {
def catchNonFatalEval[A](a: Eval[A])(implicit ev: Throwable <:< E): F[A] =
try pure(a.value)
catch {
case NonFatal(e) => raiseError(e)
case e if NonFatal(e) => raiseError(e)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ private[data] trait ValidatedFunctions {
try {
valid(f)
} catch {
case scala.util.control.NonFatal(t) => invalid(t)
case t if scala.util.control.NonFatal(t) => invalid(t)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/try.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ trait TryInstances extends TryInstances1 {
ta match {
case Success(a) => bind(a); case Failure(e) => recover(e)
}
catch { case NonFatal(e) => Failure(e) }
catch { case e if NonFatal(e) => Failure(e) }

override def recover[A](ta: Try[A])(pf: PartialFunction[Throwable, A]): Try[A] =
ta.recover(pf)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ final class EitherObjectOps(private val either: Either.type) extends AnyVal {
try {
right(f)
} catch {
case scala.util.control.NonFatal(t) => left(t)
case t if scala.util.control.NonFatal(t) => left(t)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object SerializableLaws {
ois.close()
Result(status = Proof)
} catch {
case NonFatal(t) =>
case t if NonFatal(t) =>
Result(status = Exception(t))
} finally {
oos.close()
Expand Down