Skip to content

Commit 269b36f

Browse files
committed
fix: provide ACD error description
1 parent ba3ac9a commit 269b36f

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

ibm_whcs_sdk/annotator_for_clinical_data/annotator_for_clinical_data_v1.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ class ACDException(ApiException):
3939
:param int code: The HTTP status code returned.
4040
:param str message: A message describing the error.
4141
:param str correlationId: A code to associate to the ACD error
42+
:param str errDescription: A description of the error if available.
4243
"""
4344

44-
def __init__(self, code, message=None, correlation_id=None):
45+
def __init__(self, code, message=None, correlation_id=None, err_description=None):
4546
self.message = message
4647
self.code = code
4748
self.correlation_id = correlation_id
49+
self.err_description = err_description
4850

4951
def __str__(self):
5052
msg = ('Error: ' + str(self.message) + ', Code: ' + str(self.code)
51-
+ ', CorrelationId: ' + str(self.correlation_id))
53+
+ ', CorrelationId: ' + str(self.correlation_id) + ', Description: ' + str(self.err_description))
5254
return msg
5355

5456
##############################################################################
@@ -134,9 +136,15 @@ def request_acd(self, request=None):
134136
and api_except.http_response.headers.get('x-correlation-id') is not None
135137
):
136138
correlation_id = api_except.http_response.headers.get('x-correlation-id')
139+
try:
140+
http_resp_json = api_except.http_response.json()
141+
err_description = http_resp_json['description']
142+
except:
143+
err_description = "None"
137144
else:
138145
correlation_id = "None"
139-
raise ACDException(status_code, error_message, correlation_id)
146+
err_description = "None"
147+
raise ACDException(status_code, error_message, correlation_id, err_description)
140148

141149
return final
142150

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ deps =
1919
-r{toxinidir}/requirements-dev.txt
2020
usedevelop = True
2121
exclude = .venv,.git,.tox,docs
22+
23+
[testenv:py38]
24+
install_command=python -m pip install --use-feature=fast-deps --use-deprecated=legacy-resolver {opts} {packages}

0 commit comments

Comments
 (0)