Skip to content

Commit 40c98f7

Browse files
author
Matthieu Nottale
committed
memo: Return ErrKeyNotFound from Delete and List when appropriate.
1 parent 15fd92e commit 40c98f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

store/memo/memo.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ func (s *Memo) Put(key string, value []byte, options *store.WriteOptions) error
5555
// Delete value at "key"
5656
func (s *Memo) Delete(key string) error {
5757
_, err := s.kvs.Delete(context.Background(), &kvs.DeleteRequest{Key: key})
58+
if err != nil && grpc.Code(err) == codes.NotFound {
59+
return store.ErrKeyNotFound
60+
}
5861
return err
5962
}
6063

@@ -100,6 +103,9 @@ func (s *Memo) List(directory string) ([]*store.KVPair, error) {
100103
}
101104
res = append(res, kv)
102105
}
106+
if len(res) == 0 {
107+
return nil, store.ErrKeyNotFound
108+
}
103109
return res, nil
104110
}
105111

0 commit comments

Comments
 (0)