Skip to content

Commit

Permalink
chore: Add exception chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Aug 29, 2020
1 parent 415ece4 commit 5cccb4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions postmarker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ def check_response(self, response):
except requests.HTTPError as http_error:
try:
data = response.json()
except ValueError:
raise http_error
except ValueError as exc:
raise http_error from exc
message = self.format_exception_message(data)
raise ClientError(message, error_code=data["ErrorCode"])
raise ClientError(message, error_code=data["ErrorCode"]) from http_error

def format_exception_message(self, data):
return "[{}] {}".format(data["ErrorCode"], data["Message"])

0 comments on commit 5cccb4d

Please sign in to comment.