Skip to content

Commit

Permalink
Improves error handling on reading from WS connections
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Apr 13, 2024
1 parent f0a4bd6 commit 5a76f13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions channel/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ func (c *Conn) HandleRequests() {
msgType, reader, err := c.ws.Reader(c.ctx)

if err != nil {
slog.Warn("Error reading message: " + err.Error())

return
}

data, err := io.ReadAll(reader)

if err != nil {
switch {
case errors.Is(err, io.EOF):
return
case errors.Is(err, context.Canceled):
return
}

slog.Warn("Error reading message: " + err.Error())

return
Expand Down

0 comments on commit 5a76f13

Please sign in to comment.