Skip to content

Commit

Permalink
Merge pull request #95 from mark-oppenheim/mark-oppenheim-safer-error…
Browse files Browse the repository at this point in the history
…-logging

Handle unexpected json structure in error payload
  • Loading branch information
sfc-gh-xhuang authored Aug 26, 2024
2 parents cd6eb68 + bb19393 commit daa25c3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions snowflake/ingest/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ 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

def __str__(self):
Expand Down

0 comments on commit daa25c3

Please sign in to comment.