Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/citrine/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ def checked_request(self, method: str, path: str,
self._refresh_access_token()
response = self._request_with_retry(method, uri, **kwargs)
except AttributeError:
# Catch AttributeErrors and log response
# The 401 status will be handled further down
logger.error("Failed to decode json from response: {}".format(response.text))
# json() returned non-dict (e.g. list/string); 401 handled below
logger.debug("Response JSON is not a dict (status %s): %s",
response.status_code, response.text[:200])
except ValueError:
# Ignore ValueErrors thrown by attempting to decode json bodies. This
# might occur if we get a 401 response without a JSON body
pass
# Response has no JSON body (common for 401); 401 handled below
logger.debug("Response with status %s has no JSON body",
response.status_code)

if 200 <= response.status_code <= 299:
logger.info('%s %s %s', response.status_code, method, path)
Expand Down Expand Up @@ -258,11 +258,11 @@ def _extract_response_json(path, response) -> dict:
lacked the required 'application/json' Content-Type in the header.""")

except JSONDecodeError as err:
logger.info('Response at path %s with status code %s failed json parsing with'
' exception %s. Returning empty value.',
path,
response.status_code,
err.msg)
logger.warning(
'Response at path %s with status code %s failed JSON '
'parsing (%s). Returning empty dict — downstream code '
'may behave unexpectedly.',
path, response.status_code, err.msg)

return extracted_response

Expand Down
Loading