This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 0ccd96aa047a95fa754e0893d9b829c74c9a5e15
Author: Maxim Martynov <[email protected]>
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 <[email protected]>
    (cherry picked from commit a43ed6c11d3ca3c8a63b86981c3241365eb60b79)
---
 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)

Reply via email to