Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arbha1erao committed Feb 17, 2025
1 parent e3911d6 commit cf83f04
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rueidiscompat/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5182,15 +5182,20 @@ func (cmd *LCSCmd) from(res rueidis.RedisResult) {
// match string
if lcs.MatchString, err = res.ToString(); err != nil {
cmd.SetErr(err)
return
}
case 2:
// match len
if lcs.Len, err = res.AsInt64(); err != nil {
cmd.SetErr(err)
return
}
case 3:
// read LCSMatch
if msgMap, err := res.AsMap(); err == nil {
if msgMap, err := res.AsMap(); err != nil {
cmd.SetErr(err)
return
} else {
// Validate length (should have exactly 2 keys: "matches" and "len")
if len(msgMap) != 2 {
cmd.SetErr(fmt.Errorf("redis: got %d elements in the map, wanted %d", len(msgMap), 2))
Expand Down

0 comments on commit cf83f04

Please sign in to comment.