From 6bbe00f0c7aae6c468b1a3e12983a74a170e92b8 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 8 Dec 2024 10:32:29 +0800 Subject: Handle send failures --- cmd_user.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'cmd_user.go') diff --git a/cmd_user.go b/cmd_user.go index 06fd7a3..4c4c86a 100644 --- a/cmd_user.go +++ b/cmd_user.go @@ -8,19 +8,24 @@ func init() { commandHandlers["USER"] = handleClientUser } -func handleClientUser(msg RMsg, client *Client) bool { +func handleClientUser(msg RMsg, client *Client) error { if len(msg.Params) < 4 { - client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "USER", "Not enough parameters")) - return true + return client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "USER", "Not enough parameters")) } switch client.State { case ClientStatePreRegistration: client.Ident = "~" + msg.Params[0] client.Gecos = msg.Params[3] - client.checkRegistration() + err := client.checkRegistration() + if err != nil { + return err + } case ClientStateRegistered: - client.Send(MakeMsg(self, ERR_ALREADYREGISTERED, client.Nick, "You may not reregister")) + err := client.Send(MakeMsg(self, ERR_ALREADYREGISTERED, client.Nick, "You may not reregister")) + if err != nil { + return err + } case ClientStateRemote: } - return true + return nil } -- cgit v1.2.3