Skip to content

Commit

Permalink
add handling in validating response if error is a list (#19)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Hassan Syyid <hassansyyid@gmail.com>
  • Loading branch information
keyn4 and hsyyid authored Oct 30, 2024
1 parent 44c6cfd commit 0bc6e8b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/tap_intacct/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,14 @@ def _post_request(self, dict_body: dict, api_url: str) -> Dict:
if api_response['result']['status'] == 'success':
return api_response

logger.error(f"Intacct error response: {api_response}")
error = api_response.get('result', {}).get('errormessage', {}).get('error', {})
desc_2 = error.get("description2") if isinstance(error, dict) else error[0].get("description2") if isinstance(error, list) and error else ""
if (
api_response['result']['status'] == 'failure'
and api_response.get('result', {}).get('errormessage', {}).get('error', {}).get('description2')
and error
and "There was an error processing the request"
in api_response['result']['errormessage']['error']['description2']
in desc_2
and dict_body["request"]["operation"]["content"]["function"]["query"][
"object"
]
Expand Down

0 comments on commit 0bc6e8b

Please sign in to comment.