Skip to content

Commit

Permalink
Better error msg for Uci decoder & code tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Mar 25, 2024
1 parent d04608e commit 2ed69c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/src/main/scala/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ opaque type BestMove = Uci
object BestMove:
def apply(value: Uci): BestMove = value
given Encoder[BestMove] = encodeString.contramap(_.uci)
given Decoder[BestMove] = decodeString.emap(Uci.apply(_).toRight("Invalid Uci"))
given Decoder[BestMove] = decodeString.emap(s => Uci(s).toRight(s"Invalid Uci: $s"))
extension (bm: BestMove) def value: Uci = bm

opaque type WorkId = String
object WorkId:
def apply(value: String): WorkId = value
given Encoder[WorkId] = encodeString
given Decoder[WorkId] = decodeString
extension (bm: WorkId) def value: String = bm
extension (id: WorkId) def value: String = id

opaque type GameId = String
object GameId:
def apply(value: String): GameId = value
given Encoder[GameId] = encodeString
given Decoder[GameId] = decodeString
extension (bm: GameId) def value: String = bm
extension (id: GameId) def value: String = id

object ChessCirceCodecs:
given Encoder[Fen.Epd] = encodeString.contramap(_.value)
Expand Down

0 comments on commit 2ed69c8

Please sign in to comment.