report read limit violations on EventDisconnected via ErrReadLimit sentinel

This commit is contained in:
Jay
2026-08-10 16:02:57 -04:00
parent 19810798a7
commit 7851d22c22
4 changed files with 91 additions and 6 deletions
+7 -1
View File
@@ -27,6 +27,7 @@ var (
ErrPeerClosedClean = errors.New("peer closed connection cleanly")
ErrPeerClosedUnexpected = errors.New("peer closed connection unexpectedly")
ErrReadError = errors.New("read error")
ErrReadLimit = errors.New("read limit exceeded")
)
// ----------------------------------------------------------------------------
@@ -350,7 +351,12 @@ func (c *Connection) classifyCloseError(err error) error {
}
}
classifiedError = fmt.Errorf("%w: %w", ErrReadError, err)
if errors.Is(err, websocket.ErrReadLimit) {
classifiedError = fmt.Errorf("%w: %w: %v",
ErrReadError, ErrReadLimit, err)
} else {
classifiedError = fmt.Errorf("%w: %w", ErrReadError, err)
}
}
return classifiedError