Commit 34bf8ae6 authored by Steven Allen's avatar Steven Allen

fix: wrap invalid key error on put

parent 4ca877d4
......@@ -95,6 +95,7 @@ var (
ErrDatastoreDoesNotExist = errors.New("datastore directory does not exist")
ErrShardingFileMissing = fmt.Errorf("%s file not found in datastore", SHARDING_FN)
ErrClosed = errors.New("datastore closed")
ErrInvalidKey = errors.New("key not supported by flatfs")
)
func init() {
......@@ -362,7 +363,7 @@ var putMaxRetries = 6
// will win.
func (fs *Datastore) Put(key datastore.Key, value []byte) error {
if !keyIsValid(key) {
return fmt.Errorf("key not supported by flatfs: '%q'", key)
return fmt.Errorf("when putting '%q': %w", key, ErrInvalidKey)
}
fs.shutdownLock.RLock()
......@@ -1138,7 +1139,7 @@ func (fs *Datastore) Batch() (datastore.Batch, error) {
func (bt *flatfsBatch) Put(key datastore.Key, val []byte) error {
if !keyIsValid(key) {
return fmt.Errorf("key not supported by flatfs: '%q'", key)
return fmt.Errorf("when putting '%q': %w", key, ErrInvalidKey)
}
bt.puts[key] = val
return nil
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment