Skip to content

Commit

Permalink
Add response information for debugging (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
visch authored Dec 27, 2024
1 parent d77e8d8 commit c8232d1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tap_adp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,29 @@ def has_more(self, response: requests.Response) -> bool:
`True` if pagination should continue, `False` if a 204 No Content is received.
"""
return response.status_code != 204

def response_error_message(self, response: requests.Response) -> str:
"""Build error message for invalid http statuses.
WARNING - Override this method when the URL path may contain secrets or PII
Args:
response: A :class:`requests.Response` object.
Returns:
str: The error message
"""
full_path = urlparse(response.url).path or self.path
error_type = (
"Client"
if HTTPStatus.BAD_REQUEST
<= response.status_code
< HTTPStatus.INTERNAL_SERVER_ERROR
else "Server"
)

return (
f"{response.status_code} {error_type} Error: "
f"{response.reason} for path: {full_path}."
f"Response: {response.json()}"
)

0 comments on commit c8232d1

Please sign in to comment.