From 8ee37abca2f15097e1a8315f2ee94b4cb0a50478 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 18 Sep 2024 12:29:42 +0200 Subject: [PATCH] Refactor error handling in message sending loop Changed from range over messages to range with index to correctly update sendError field in the original messages slice. This prevents shadowing issues and ensures proper error logging for each message. --- client_120.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client_120.go b/client_120.go index 60e8e3c..757a951 100644 --- a/client_120.go +++ b/client_120.go @@ -24,9 +24,9 @@ func (c *Client) Send(messages ...*Msg) (returnErr error) { returnErr = errors.Join(errs...) }() - for _, message := range messages { + for id, message := range messages { if sendErr := c.sendSingleMsg(message); sendErr != nil { - message.sendError = sendErr + messages[id].sendError = sendErr errs = append(errs, sendErr) } }