Skip to content

Commit

Permalink
make debugging consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
pcmxgti committed Dec 7, 2023
1 parent 099cf04 commit 5b72434
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tokendito/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def get(self, url, params=None, headers=None, allow_redirects=True):

def post(self, url, data=None, json=None, headers=None, params=None, return_json=False):
"""Perform a POST request."""
response = None
logger.debug(f"POST to {url}")
try:
response = self.session.post(url, data=data, json=json, params=params, headers=headers)
Expand All @@ -95,6 +96,11 @@ def post(self, url, data=None, json=None, headers=None, params=None, return_json
return response
except requests.RequestException as e:
logger.error(f"Error during POST request to {url}. Error: {e}")
if response:
logger.debug(f"Response Headers: {response.headers}")
logger.debug(f"Response Text: {response.text}")
else:
logger.debug("No response received")
sys.exit(1)
except Exception as err:
logger.error(f"The post request to {url} failed with {err}")
Expand Down

0 comments on commit 5b72434

Please sign in to comment.