Skip to content

Commit

Permalink
Add missing logout case
Browse files Browse the repository at this point in the history
  • Loading branch information
nanomad committed Oct 8, 2024
1 parent 01c3eb1 commit 2b9aa47
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/saic_ismart_client_ng/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import dacite
import httpx
import tenacity
from httpx import TimeoutException
from httpx._types import QueryParamTypes, HeaderTypes

from saic_ismart_client_ng.api.schema import LoginResp
Expand Down Expand Up @@ -181,15 +182,15 @@ async def deserialize(
raise se
except Exception as e:
if response.is_error:
if response.status_code == 401:
await self._handle_logout(
error_message=response.text,
return_code=response.status_code,
response=response,
if response.status_code in (401, 403):
logger.error(
f"API call failed due to an authentication failure: {response.status_code} {response.text}"
)
self.logout()
raise SaicLogoutException(response.text, response.status_code)
else:
logger.error(f"API call failed: {response.text}")
raise SaicApiException(f"API call failed with status code {response.status_code}: {response.text}")
logger.error(f"API call failed: {response.status_code} {response.text}")
raise SaicApiException(response.text, response.status_code)
else:
raise SaicApiException(f"Failed to deserialize response: {e}. Original json was {response.text}") from e

Expand Down

0 comments on commit 2b9aa47

Please sign in to comment.