Skip to content

Commit

Permalink
Include remote server 404 errors as a problem in debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh5 committed Feb 17, 2024
1 parent 2f8eaa6 commit 377bf74
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions unmanic/libs/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ def api_get(self, api_prefix, api_version, api_path):
"""
u = self.set_full_api_url(api_prefix, api_version, api_path)
r = self.requests_session.get(u, timeout=self.timeout)
if r.status_code >= 500:
self.logger.debug("Sorry! There seems to be an issue with the remote servers. Please try again later.")
return {}, r.status_code
if r.status_code > 403:
self.logger.debug(
"Sorry! There seems to be an issue with the remote servers. Please try again later. Status code %s",
r.status_code)
if r.status_code == 401:
# Verify the token. Refresh as required
token_verified = self.verify_token()
Expand All @@ -324,9 +325,10 @@ def api_post(self, api_prefix, api_version, api_path, data):
"""
u = self.set_full_api_url(api_prefix, api_version, api_path)
r = self.requests_session.post(u, json=data, timeout=self.timeout)
if r.status_code >= 500:
self.logger.debug("Sorry! There seems to be an issue with the remote servers. Please try again later.")
return {}, r.status_code
if r.status_code > 403:
self.logger.debug(
"Sorry! There seems to be an issue with the remote servers. Please try again later. Status code %s",
r.status_code)
if r.status_code == 401:
# Verify the token. Refresh as required
token_verified = self.verify_token()
Expand All @@ -344,17 +346,21 @@ def verify_token(self):
# Check if access token is valid
u = self.set_full_api_url('support-auth-api', 1, 'user_auth/verify_token')
r = self.requests_session.get(u, timeout=self.timeout)
if r.status_code >= 500:
self.logger.debug("Sorry! There seems to be an issue with the token auth servers. Please try again later.")
if r.status_code > 403:
self.logger.debug(
"Sorry! There seems to be an issue with the token auth servers. Please try again later. Status code %s",
r.status_code)
# Return True here to prevent the app from lowering the level
return True
if r.status_code not in [202]:
self._log("Unable to verify authentication token. Refreshing...", level="debug")
u = self.set_full_api_url('support-auth-api', 1, 'user_auth/refresh_token')
r = self.requests_session.get(u, timeout=self.timeout)
if r.status_code not in [202]:
if r.status_code >= 500:
self.logger.debug("Sorry! There seems to be an issue with the auth servers. Please try again later.")
if r.status_code > 403:
self.logger.debug(
"Sorry! There seems to be an issue with the auth servers. Please try again later. Status code %s",
r.status_code)
# Return True here to prevent the app from lowering the level
return True
response = r.json()
Expand Down

0 comments on commit 377bf74

Please sign in to comment.