You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2022/11/07 08:35:24 UTC
[atlas] 02/04: ATLAS-4676: do not expect response body to be a valid JSON
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit a43ed6c11d3ca3c8a63b86981c3241365eb60b79
Author: Maxim Martynov <ma...@mail.ru>
AuthorDate: Fri Sep 16 17:32:39 2022 +0300
ATLAS-4676: do not expect response body to be a valid JSON
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
---
intg/src/main/python/apache_atlas/exceptions.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/intg/src/main/python/apache_atlas/exceptions.py b/intg/src/main/python/apache_atlas/exceptions.py
index 092a45f3e..812ba1fbd 100644
--- a/intg/src/main/python/apache_atlas/exceptions.py
+++ b/intg/src/main/python/apache_atlas/exceptions.py
@@ -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)