Skip to content

Commit

Permalink
Merge pull request #4 from dfips/main
Browse files Browse the repository at this point in the history
Add exception to handle login issues of gigya client
  • Loading branch information
Woyken authored Jan 29, 2024
2 parents 6a1d973 + 6a094c4 commit 3b65e37
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pyelectroluxocp/gigyaClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ async def login_session(self, username: str, password: str, gmid: str, ucid: str
) as response:
response.raise_for_status()
data: LoginResponse = await response.json(content_type=None)
try:
if data['errorCode'] > 0:
error_code=data['errorCode']
error_details=data['errorDetails']
raise LoginError(f'Error during login: Code {error_code} ({error_details})')
except KeyError:
raise LoginError('Unknown error during login')
return data

async def get_JWT(
Expand Down Expand Up @@ -224,3 +231,7 @@ async def __aexit__(
exc_tb: Optional[TracebackType],
) -> Optional[bool]:
await self.close()

class LoginError(Exception):
'''Raised when login fails'''
pass

0 comments on commit 3b65e37

Please sign in to comment.