chargebee-python icon indicating copy to clipboard operation
chargebee-python copied to clipboard

Include response headers in exceptions

Open brian-vanderford opened this issue 2 years ago • 1 comments

I wanted to honor Retry-After when handling 429, but response headers weren't available. This PR adds thems to APIError.

brian-vanderford avatar Apr 05 '23 21:04 brian-vanderford

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Apr 05 '23 21:04 sonarqubecloud[bot]

+1.

Any chance this can get looked at for merging? We're looking to start using this package on our end when integrating with Chargebee and https://apidocs.chargebee.com/docs/api/error-handling?lang=python#error_handling mentions the best practice is to handle this header when rate limited.

MikeFE avatar Nov 30 '24 01:11 MikeFE

Hi @brian-vanderford & @MikeFE, sorry for the delay! This has been included in v2.47.1. Could you please test it and let us know if it works?

cb-alish avatar Dec 04 '24 11:12 cb-alish

Hi @brian-vanderford & @MikeFE, sorry for the delay! This has been included in v2.47.1. Could you please test it and let us know if it works?

Yeah it works, thanks a lot!

I wrote a quick script to hit the test site API and get rate limited. http_headers is now in the exception: image

It came out as an OperationFailedError w/ http_code=429, error_code='api_request_limit_exceeded'. http_headers includes Retry-After:

image

MikeFE avatar Dec 05 '24 02:12 MikeFE