Cleanup: simplify requests backend raise_for_status

Treat all 2xx (not just 200) as success in base
AnymailRequestsBackend.raise_for_status, eliminating
some unnecessary subclass overrides.
This commit is contained in:
medmunds
2020-09-11 12:06:23 -07:00
committed by Mike Edmunds
parent a14276e765
commit feee8b5c5a
3 changed files with 5 additions and 18 deletions

View File

@@ -87,9 +87,10 @@ class AnymailRequestsBackend(AnymailBaseBackend):
(though should defer parsing/deserialization of the body to
parse_recipient_status)
"""
if response.status_code != 200:
raise AnymailRequestsAPIError(email_message=message, payload=payload, response=response,
backend=self)
if response.status_code < 200 or response.status_code >= 300:
raise AnymailRequestsAPIError(
email_message=message, payload=payload,
response=response, backend=self)
def deserialize_json_response(self, response, payload, message):
"""Deserialize an ESP API response that's in json.