mozmeao/basket

Include error JSON in CTMS errors

Closed this issue · 0 comments

CTMS reports failed statuses with raise_for_status, like:

resp = self.session.patch(f"/ctms/{email_id}", json=data)
resp.raise_for_status()
return resp.json()

In Sentry, this reports:

  • The status code (such as 422)
  • The reason (such as "Unprocessable Entity")
  • A summary message (such as "422 Client Error: Unprocessable Entity for url: https://ctms.stage.mozilla-ess.mozit.cloud/ctms/{email_id}"

For a 422 and other errors, the JSON body of the response also has information, which is useful for diagnosing the error, and should be included in the context sent to Sentry