Skip to content

Commit

Permalink
ATLAS-4676: do not expect response body to be a valid JSON
Browse files Browse the repository at this point in the history
Signed-off-by: Madhan Neethiraj <[email protected]>
(cherry picked from commit a43ed6c)
  • Loading branch information
dolfinus authored and mneethiraj committed Nov 7, 2022
1 parent 956cac4 commit 0ccd96a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions intg/src/main/python/apache_atlas/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ class AtlasServiceException(Exception):
"""

def __init__(self, api, response):
msg = ""
body = ""

if api:
msg = "Metadata service API {method} : {path} failed".format(**{'method': api.method, 'path': api.path})
if response.content:
try:
body = response.json()
except Exception:
body = response.content

if response.content is not None:
status = response.status_code if response.status_code is not None else -1
msg = "Metadata service API with url {url} and method {method} : failed with status {status} and " \
"Response Body is :{response}". \
format(**{'url': response.url, 'method': api.method, 'status': status, 'response': response.json()})
msg = "Metadata service API {method} {path} failed with status {status}. Response body is: {body}".format(**{'method': api.method, 'path': api.path, 'status': response.status_code, 'body': body})

Exception.__init__(self, msg)

0 comments on commit 0ccd96a

Please sign in to comment.