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

HTTP4S Generator: Add headers to FailedRequest model #627

Open
barryoneill opened this issue Feb 17, 2021 · 3 comments
Open

HTTP4S Generator: Add headers to FailedRequest model #627

barryoneill opened this issue Feb 17, 2021 · 3 comments

Comments

@barryoneill
Copy link
Contributor

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.

@gheine
Copy link
Collaborator

gheine commented Feb 19, 2021

@barryoneill we'd be happy to consider your PR ;-)

@barryoneill
Copy link
Contributor Author

Just a moment while I convert it all to tagless final :)

@gheine
Copy link
Collaborator

gheine commented Feb 19, 2021

/unsubscribe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants