Coverage for atlas_ecommerce/clients/delivery.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-25 16:36 +0000

1import httpx 

2 

3 

4class TransientDeliveryError(Exception): 

5 """The destination did not take the event this time; retrying may work.""" 

6 

7 

8class PermanentDeliveryError(Exception): 

9 """The destination rejected the event; retrying cannot help.""" 

10 

11 

12def raise_for_response(response: httpx.Response) -> None: 

13 if response.is_success: 

14 return 

15 detail = f"{response.status_code} {response.text[:300]}" 

16 if response.status_code in (408, 429) or response.status_code >= 500: 

17 raise TransientDeliveryError(detail) 

18 raise PermanentDeliveryError(detail)