I have created hierarchy of errors:
sealed trait MyError extends Throwable
final case class SecondError(msg: String) extends MyError
Now I could get this kind of error in my http4s
routes:
case GET -> Root / "things" => for {
response <- things.all.foldM(
error => error match {
case SecondError(_) => InternalServerError(error)
}
...
But I get compiled error:
could not find implicit value for parameter encoder: io.circe.Encoder[Throwable]
Is it possible to encode Throwable
with circe
and http4s
? I tried to do it this way:
implicit def encoderHttpThrowable: EntityEncoder[Env, Throwable] = jsonEncoderOf[Env, Throwable]
But it did not solve a problem.