ing-bank / scruid

Scala + Druid: Scruid. A library that allows you to compose queries in Scala, and parse the result back into typesafe classes.
Apache License 2.0
115 stars 29 forks source link

Add protocol and headers to HttpStatusException #70

Closed barend closed 4 years ago

barend commented 4 years ago

This is an improvement to my earlier PR #67. I realised that I had forgotten to include the response headers in the HttpStatusException. While making the change, I decided to also add the protocol, which is the only other field in HttpResponse.

I did not simply embed HttpResponse because HttpResponse.toStrict doesn't change the object type the way HttpEntity.toStrict does. This means that there was no way (that I can find) to make the exception fields accessible without having to provide all the async context.

Finally, this commit changes the Option[HttpEntity.Strict] in the exception type to a Try[HttpEntity.Strict]. This ensures that if an exception occurs while reading the response body, neither the non-200 status code nor this exception are lost.

All unit tests pass.

barend commented 4 years ago

@mmartina I have addressed all your comments. Thank you for the super detailed review.