Skip to content

Commit 737839a

Browse files
committed
SDK-1582: Split format message method
1 parent 4e342ab commit 737839a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

yoti_python_sdk/doc_scan/exception/doc_scan_exception.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, message, response):
1616
"""
1717
Exception.__init__(self)
1818

19-
response_message = self.__format_response_message(response)
19+
response_message = self.__get_response_message(response)
2020

2121
self.__message = message + (
2222
" - " + response_message if response_message else ""
@@ -63,18 +63,25 @@ def content(self):
6363
"""
6464
return self.__response.content
6565

66-
def __format_response_message(self, response):
66+
def __get_response_message(self, response):
6767
"""
6868
Return the formatted response message
6969
7070
:return: the formatted message
7171
:rtype: string or None
7272
"""
73-
if response.headers.get("Content-Type") != "application/json":
74-
return None
73+
if response.headers.get("Content-Type") == "application/json":
74+
return self.__format_json_response_message(json.loads(response.text))
75+
76+
return None
7577

76-
parsed = json.loads(response.text)
78+
def __format_json_response_message(self, parsed):
79+
"""
80+
Return the formatted JSON response message
7781
82+
:return: the formatted message
83+
:rtype: string or None
84+
"""
7885
if not parsed.get("code") or not parsed.get("message"):
7986
return None
8087

0 commit comments

Comments
 (0)