diff --git a/src/socketry/client.py b/src/socketry/client.py index 5b4114f..9b6f243 100644 --- a/src/socketry/client.py +++ b/src/socketry/client.py @@ -854,7 +854,7 @@ async def _http_login( if body.get("code") != 0: msg = body.get("msg", "unknown error") - raise RuntimeError(f"Login failed: {msg}") + raise AuthenticationError(f"Login failed: {msg}") data = body["data"] token = body["token"] diff --git a/tests/test_client.py b/tests/test_client.py index cb7ac3d..8813a15 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -290,7 +290,7 @@ async def test_login_no_devices(self): async def test_login_failure_code(self): with aioresponses() as m: m.post(_LOGIN_URL, payload={"code": 1, "msg": "Bad credentials"}) - with pytest.raises(RuntimeError, match="Login failed: Bad credentials"): + with pytest.raises(AuthenticationError, match="Login failed: Bad credentials"): await _http_login("bad@example.com", "wrong") async def test_login_http_error(self):