Skip to content

Commit

Permalink
fix: two error messages for failed authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Mar 12, 2024
1 parent 537b14c commit 093663c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/dumdum/client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)

from .async_client import AsyncClient
from .errors import AuthenticationFailedError
from .event_thread import EventThread
from .store import ClientStore

Expand Down Expand Up @@ -150,6 +151,12 @@ def _on_connection_lost(self, event: Event) -> None:
elif isinstance(exc, asyncio.CancelledError):
# The user wants to close the GUI
return
elif (
isinstance(exc, BaseExceptionGroup)
and exc.subgroup(AuthenticationFailedError) is not None
):
# Handled via ClientEventAuthentication
return
else:
log.error("Lost connection with server", exc_info=exc)
messagebox.showerror("Connection Lost", str(exc))
Expand Down
4 changes: 3 additions & 1 deletion src/dumdum/client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
ClientEventIncompatibleVersion,
)

from .errors import AuthenticationFailedError


class AsyncClient:
_reader: asyncio.StreamReader | None
Expand Down Expand Up @@ -51,7 +53,7 @@ async def connect(self, host: str, port: int) -> AsyncIterator[Self]:
try:
success = await self._handshake()
if not success:
raise RuntimeError("Could not authenticate with server")
raise AuthenticationFailedError()

yield self
finally:
Expand Down

0 comments on commit 093663c

Please sign in to comment.