Skip to content

Commit

Permalink
Handle unexpected json structure in error payload
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-oppenheim committed Aug 22, 2024
1 parent ebc8c77 commit 74a2713
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions snowflake/ingest/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ def __init__(self, response: Response):
response.reason)
return

self.code = json_body[u'code']
self.success = json_body[u'success']
self._raw_message = json_body[u'message']
self.data = json_body[u'data']
self.message = 'Http Error: {}, Vender Code: {}, Message: {}'\
.format(self.http_error_code, self.code, self._raw_message)
try:
self.code = json_body[u'code']
self.success = json_body[u'success']
self._raw_message = json_body[u'message']
self.data = json_body[u'data']
self.message = 'Http Error: {}, Vender Code: {}, Message: {}' \
.format(self.http_error_code, self.code, self._raw_message)
except KeyError:
self.message = 'Http Error: {}, Message: {}, Body: {}'.format(self.http_error_code,
response.reason,
json_body)


return

Expand Down

0 comments on commit 74a2713

Please sign in to comment.