Skip to content

HTTP4S Generator: Add headers to FailedRequest model #627

@barryoneill

Description

@barryoneill

In the http4s client, when a codec fails to parse the expected JSON, it creates a FailedRequest model:

  def parseJson[F[_]: Sync, T](
      className: String,
      r: org.http4s.Response[F]
    )(implicit decoder: io.circe.Decoder[T]): F[T] = r.attemptAs[T].value.flatMap {
      case Right(value) => Sync[F].pure(value)
      case Left(error) => Sync[F].raiseError(new com.foo.bar.api.v2.errors.FailedRequest( r.status.code, s"Invalid json for class[" + className + "]", None, error))
    }

It would be desirable to have the headers from the response to be included in this FailedRequest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions