Allow a flag (simple
is used by request-promise
https://github.com/request/request-promise#api-in-detail which defaults to true
) which prevents formatting errors with a new message, body, etc. when the status code family != 2xx.
Motivation
Currently we (BBC ID) use our own https://github.com/request/request wrapper, https://github.com/bbc/id-http-client.
We began constructing this before we were aware of Flashheart's existence, and we seem to slowly be bringing it up to feature parity with Flashheart due to product/resilience needs. We'd rather not duplicate these non-product specific features in BBC estate
Ideally we'd be able to instead wrap Flashheart to gain circuit breakers, retries, rate limiting and built-in-cache, and roll our own stats and logs as we see fit (for example for statsd we use datadoghq.com, and the statsd protocol wrapper dogstatsd).
Problem
Currently we're unable to wrap Flashheart due to the change in error format from standard request
. We currently have the chain of request decoration, request -> bbc-http-client-node -> request-promise -> id-http-client
, request-promise
or id-http-client
would be unable to interpret the reformatted errors passed via 'errorback'.
If these could be returned as normal, without filtering by statusCode etc, we could in theory consume Flashheart (request -> bbc-http-client-node -> flashheart -> request-promise -> id-http-client
) while keeping the same API, with new errors thrown by Flashheart falling into request-promise
' RequestError
prototype.