Skip to content

Commit

Permalink
Use cats syntax for MonadThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Nov 9, 2024
1 parent cfa5d85 commit 434e62c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/elastic/src/main/scala/ESClient.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package lila.search

import cats.MonadThrow
import cats.effect.*
import cats.syntax.all.*
import com.sksamuel.elastic4s.ElasticDsl.*
Expand Down Expand Up @@ -76,10 +75,10 @@ object ESClient:
.map(_.status)

private def toResult[A](response: Response[A]): F[A] =
response.fold(MonadThrow[F].raiseError[A](response.error.asException))(MonadThrow[F].pure)
response.fold(response.error.asException.raiseError)(r => r.pure[F])

private def unitOrFail[A](response: Response[A]): F[Unit] =
response.fold(MonadThrow[F].raiseError[Unit](response.error.asException))(_ => MonadThrow[F].unit)
response.fold(response.error.asException.raiseError)(_ => ().pure[F])

def search[A](query: A, from: From, size: Size)(using q: Queryable[A]): F[List[Id]] =
metric
Expand Down

0 comments on commit 434e62c

Please sign in to comment.