Skip to content

Commit 2b9aa47

Browse files
committed
Add missing logout case
1 parent 01c3eb1 commit 2b9aa47

File tree

1 file changed

+8
-7
lines changed
  • src/saic_ismart_client_ng/api

1 file changed

+8
-7
lines changed

src/saic_ismart_client_ng/api/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import dacite
99
import httpx
1010
import tenacity
11+
from httpx import TimeoutException
1112
from httpx._types import QueryParamTypes, HeaderTypes
1213

1314
from saic_ismart_client_ng.api.schema import LoginResp
@@ -181,15 +182,15 @@ async def deserialize(
181182
raise se
182183
except Exception as e:
183184
if response.is_error:
184-
if response.status_code == 401:
185-
await self._handle_logout(
186-
error_message=response.text,
187-
return_code=response.status_code,
188-
response=response,
185+
if response.status_code in (401, 403):
186+
logger.error(
187+
f"API call failed due to an authentication failure: {response.status_code} {response.text}"
189188
)
189+
self.logout()
190+
raise SaicLogoutException(response.text, response.status_code)
190191
else:
191-
logger.error(f"API call failed: {response.text}")
192-
raise SaicApiException(f"API call failed with status code {response.status_code}: {response.text}")
192+
logger.error(f"API call failed: {response.status_code} {response.text}")
193+
raise SaicApiException(response.text, response.status_code)
193194
else:
194195
raise SaicApiException(f"Failed to deserialize response: {e}. Original json was {response.text}") from e
195196

0 commit comments

Comments
 (0)