Skip to content

Commit

Permalink
memo: Return ErrKeyNotFound from Delete and List when appropriate.
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Nottale <[email protected]>
  • Loading branch information
Matthieu Nottale committed Aug 7, 2017
1 parent 15fd92e commit 5d43b1e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions store/memo/memo.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (s *Memo) Put(key string, value []byte, options *store.WriteOptions) error
// Delete value at "key"
func (s *Memo) Delete(key string) error {
_, err := s.kvs.Delete(context.Background(), &kvs.DeleteRequest{Key: key})
if err != nil && grpc.Code(err) == codes.NotFound {
return store.ErrKeyNotFound
}
return err
}

Expand Down Expand Up @@ -100,6 +103,9 @@ func (s *Memo) List(directory string) ([]*store.KVPair, error) {
}
res = append(res, kv)
}
if len(res) == 0 {
return nil, store.ErrKeyNotFound
}
return res, nil
}

Expand Down

0 comments on commit 5d43b1e

Please sign in to comment.