Skip to content

Commit

Permalink
fix: provide ACD error description
Browse files Browse the repository at this point in the history
  • Loading branch information
dlangst committed Jul 23, 2021
1 parent ba3ac9a commit 269b36f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ class ACDException(ApiException):
:param int code: The HTTP status code returned.
:param str message: A message describing the error.
:param str correlationId: A code to associate to the ACD error
:param str errDescription: A description of the error if available.
"""

def __init__(self, code, message=None, correlation_id=None):
def __init__(self, code, message=None, correlation_id=None, err_description=None):
self.message = message
self.code = code
self.correlation_id = correlation_id
self.err_description = err_description

def __str__(self):
msg = ('Error: ' + str(self.message) + ', Code: ' + str(self.code)
+ ', CorrelationId: ' + str(self.correlation_id))
+ ', CorrelationId: ' + str(self.correlation_id) + ', Description: ' + str(self.err_description))
return msg

##############################################################################
Expand Down Expand Up @@ -134,9 +136,15 @@ def request_acd(self, request=None):
and api_except.http_response.headers.get('x-correlation-id') is not None
):
correlation_id = api_except.http_response.headers.get('x-correlation-id')
try:
http_resp_json = api_except.http_response.json()
err_description = http_resp_json['description']
except:
err_description = "None"
else:
correlation_id = "None"
raise ACDException(status_code, error_message, correlation_id)
err_description = "None"
raise ACDException(status_code, error_message, correlation_id, err_description)

return final

Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ deps =
-r{toxinidir}/requirements-dev.txt
usedevelop = True
exclude = .venv,.git,.tox,docs

[testenv:py38]
install_command=python -m pip install --use-feature=fast-deps --use-deprecated=legacy-resolver {opts} {packages}

0 comments on commit 269b36f

Please sign in to comment.