Skip to content

Commit

Permalink
fix: meaningful error when authentication fails
Browse files Browse the repository at this point in the history
Fixes #83
  • Loading branch information
Mai Minh Pham committed Apr 17, 2024
1 parent d117021 commit b56a667
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ async def login(self):
data = {"email": self.username, "password": self.password}
async with self.clientsession.post(login_url, json=data) as r:
login_result = await r.json()
self.token = login_result["loginToken"]
self.token = login_result.get("loginToken", None)
if self.token is None:
err_msg = f"Login failed. Response received: {login_result}"
raise ValueError(err_msg)

api_chat_url = f"{self.api_url}chat"
headers = {
Expand Down

0 comments on commit b56a667

Please sign in to comment.