mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Improve ESP response formatting in error messages
This commit is contained in:
@@ -75,13 +75,13 @@ class AnymailError(Exception):
|
|||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
reason = reason.decode('iso-8859-1')
|
reason = reason.decode('iso-8859-1')
|
||||||
|
|
||||||
description = "%s API response %d: %s" % (self.esp_name or "ESP", self.status_code, reason)
|
description = "%s API response %d (%s)" % (self.esp_name or "ESP", self.status_code, reason)
|
||||||
try:
|
try:
|
||||||
json_response = self.response.json()
|
json_response = self.response.json()
|
||||||
description += "\n" + json.dumps(json_response, indent=2)
|
description += ":\n" + json.dumps(json_response, indent=2)
|
||||||
except (AttributeError, KeyError, ValueError): # not JSON = ValueError
|
except (AttributeError, KeyError, ValueError): # not JSON = ValueError
|
||||||
try:
|
try:
|
||||||
description += " " + self.response.text
|
description += ": %r" % self.response.text
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
return description
|
return description
|
||||||
|
|||||||
Reference in New Issue
Block a user