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

Release/1.1.1 #167

Closed
wants to merge 3 commits into from
Closed

Release/1.1.1 #167

wants to merge 3 commits into from

Conversation

chuwy
Copy link
Contributor

@chuwy chuwy commented Aug 5, 2021

No description provided.

}
}

responseResult.attempt.map {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quite like .handleError instead of .attempt for this kind of thing

): F[Either[RegistryError, A]] = {
val responseResult = client.run(req).use[F, Either[RegistryError, A]] {
case Status.Successful(response) =>
response.as[A].map(_.asRight)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think .as[A] can raise an error in F if the body cannot be parsed as expected. (I'm only 80% certain on that - need to check). Is it OK to let the error bubble up, or should this be caught immediately and converted to one of the failure classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I think likely we are stumbling upon this infamous #152 because the body is trimmed.

response
.as[A]
.map(_.asRight[RegistryError])
.handleError {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is exactly what I just said to do..... but I'm looking at it again and wondering if it was the right thing 🤦‍♂️. Because you already handle the error later on at line 134. And also it's inconsistent, because there are other places where you don't catch errors that might get raised (e.g. response.bodyText.compile.string). I guess you've added an informative error message, so maybe it is better.

Oh also..... I think that methods like handleError are guaranteed to be called with non-fatal exceptions only. So it shouldn't be necessary to pattern match on NonFatal. However, I never found good documentation on this - I think I just read it somewhere in a gitter channel.

I don't suggest changing anything though. This is all good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think there's still a slight difference that would help us to catch trimmed payloads.

On line 134 I catch very IO-ish client exceptions, i.e. network is unavailable, connection pool issue etc. Whereas this handleError is specifically about things like decoding failure due trimming or dropped connection and we'll get different error messages.

Although that's post-rationalisation - I also haven't realised the exceptions is caught.

@chuwy chuwy closed this Feb 16, 2022
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

Successfully merging this pull request may close these issues.

2 participants