Client (unittest)

- Added try-and-catch

Client

- Fixed error handling in `joinChannel(string)`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-11-18 11:42:35 +02:00
parent 4ad56763d8
commit b465585e91
1 changed files with 15 additions and 8 deletions

View File

@ -164,21 +164,20 @@ public class DanteClient
writeln("Hallo");
writeln("Hallo");
// TODO: For absolute sanity we should check that
// ... it actually decoded to the type we EXPECT
// ... to be here (this would safeguard against
// ... bad server implementations)
// TODO: Make teh below a `mixin template`
ChannelMembership responseCommand = cast(ChannelMembership)response.getCommand();
Command responseCommand = response.getCommand();
ChannelMembership chanMemResp = cast(ChannelMembership)responseCommand;
if(responseCommand is null)
if(chanMemResp is null)
{
throw ProtocolException.expectedMessageKind(ChannelMembership.classinfo, responseCommand);
}
if(responseCommand.wasGood())
if(chanMemResp.wasGood())
{
return;
}
@ -334,9 +333,17 @@ unittest
DanteClient client = new DanteClient(new UnixAddress("/tmp/renaissance.sock"));
client.start();
writeln("Joining channel #general...");
client.joinChannel("#general");
writeln("Joined");
try
{
writeln("Joining channel #general...");
client.joinChannel("#general");
writeln("Joined");
}
catch(DanteException e)
{
writeln("Got exception: ", e);
}
// string[] members = client.getMembers("#general");