Update command.go

This commit is contained in:
hible 2023-05-05 22:33:22 +08:00
parent 2772a6137f
commit 99cfdfbeac
1 changed files with 12 additions and 7 deletions

View File

@ -1453,14 +1453,19 @@ func readXMessageSlice(rd *proto.Reader) ([]XMessage, error) {
} }
msgs := make([]XMessage, 0, n) msgs := make([]XMessage, 0, n)
if n > 0 {
var firstError error
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if xMessage, err := readXMessage(rd); err == nil { if xMessage, err := readXMessage(rd); err == nil {
msgs = append(msgs, xMessage) msgs = append(msgs, xMessage)
} else if firstError == nil {
firstError = err
} }
} }
if len(msgs) < 1 { if len(msgs) < 1 && firstError != nil {
// Compatible with previous returns // Compatible with previous returns
return nil, Nil return nil, firstError
}
} }
return msgs, nil return msgs, nil
} }