Skip to content

Commit f48c6db

Browse files
committed
fix: invalid username should raise login error exception
1 parent 69fb463 commit f48c6db

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/blueair_api/http_blueair.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from .util_http import request_with_logging
77
from .const import API_KEY
8-
from .errors import AuthError
8+
from .errors import LoginError
99

1010
_LOGGER = logging.getLogger(__name__)
1111

@@ -69,6 +69,8 @@ async def _get_home_host(self) -> str:
6969
url=url, headers=headers
7070
)
7171
)
72+
if response.status == 404:
73+
raise LoginError("invalid username")
7274
return (await response.text()).replace('"', "")
7375

7476
async def _get_auth_token(self) -> str:
@@ -91,11 +93,11 @@ async def _get_auth_token(self) -> str:
9193
)
9294
result = await response.text()
9395
if response.status == 404:
94-
raise AuthError("invalid username")
96+
raise LoginError("invalid username")
9597
if result == "true":
9698
return response.headers["X-AUTH-TOKEN"]
9799
else:
98-
raise AuthError("invalid password")
100+
raise LoginError("invalid password")
99101

100102
async def get_devices(self) -> list[dict[str, any]]:
101103
"""

0 commit comments

Comments
 (0)