getndazn / dazn-lambda-powertools

Powertools (logger, HTTP client, AWS clients, middlewares, patterns) for Lambda functions.
https://getndazn.github.io/dazn-lambda-powertools
MIT License
740 stars 77 forks source link

Propagate HTTP response headers in error conditions #235

Closed jwisepax8 closed 4 years ago

jwisepax8 commented 4 years ago

This is a Feature Proposal

Description

There are two error conditions that I've come across where I no longer have access to the HTTP response headers.

  1. Parsing errors caused by malformed JSON in a response body. I think the behavior for this specific case can be generalize to include many errors thrown while handling the response.

  2. HTTP errors of the 3xx, 4xx, and 5xx variety. This case appears to be handled by this line. While the headers are available at this point, they don't appear to be included in the error thrown from the library.

Similar or dependent issues: None

ipfefferpax8 commented 4 years ago

I would also recommend returning the statusText of an Http Message