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_cap.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'cmd_cap.go') diff --git a/cmd_cap.go b/cmd_cap.go index a984c07..328bce6 100644 --- a/cmd_cap.go +++ b/cmd_cap.go @@ -8,15 +8,21 @@ func init() { commandHandlers["CAP"] = handleClientCap } -func handleClientCap(msg RMsg, client *Client) bool { +func handleClientCap(msg RMsg, client *Client) error { if len(msg.Params) < 1 { - client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "CAP", "Not enough parameters")) - return true + err := client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "CAP", "Not enough parameters")) + if err != nil { + return err + } + return nil } switch strings.ToUpper(msg.Params[0]) { case "LS": - client.Send(MakeMsg(self, "CAP", client.Nick, "LS", "sasl=PLAIN,EXTERNAL")) + err := client.Send(MakeMsg(self, "CAP", client.Nick, "LS", "sasl=PLAIN,EXTERNAL")) + if err != nil { + return err + } case "REQ": } - return true + return nil } -- cgit v1.2.3