mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
fix stuttering StoreValueUnsetError
This commit is contained in:
parent
5660f813f0
commit
b1818ba089
@ -73,7 +73,7 @@ func (s *EtcdStore) Get(request string) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
if values.Count == 0 {
|
||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
||||
return nil, &ValueUnsetError{requestedValue: request}
|
||||
}
|
||||
if values.Count == 1 {
|
||||
return values.Kvs[0].Value, nil
|
||||
@ -150,7 +150,7 @@ func (t *EtcdTransaction) Get(request string) ([]byte, error) {
|
||||
return value, nil
|
||||
}
|
||||
if _, ok := t.dataDelete[request]; ok {
|
||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
||||
return nil, &ValueUnsetError{requestedValue: request}
|
||||
}
|
||||
return t.store.Get(request)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func (s *StdStore) Get(request string) ([]byte, error) {
|
||||
if ok {
|
||||
return []byte(value), nil
|
||||
}
|
||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
||||
return nil, &ValueUnsetError{requestedValue: request}
|
||||
}
|
||||
|
||||
// Put saves a value in StdStore by Type and Name.
|
||||
@ -119,7 +119,7 @@ func (t *stdTransaction) Get(request string) ([]byte, error) {
|
||||
if value, ok := t.data[request]; ok {
|
||||
return []byte(value), nil
|
||||
}
|
||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
||||
return nil, &ValueUnsetError{requestedValue: request}
|
||||
}
|
||||
|
||||
// Put saves a value.
|
||||
|
@ -44,12 +44,12 @@ type Iterator interface {
|
||||
HasNext() bool
|
||||
}
|
||||
|
||||
// StoreValueUnsetError is an error raised by unset values in the store.
|
||||
type StoreValueUnsetError struct {
|
||||
// ValueUnsetError is an error raised by unset values in the store.
|
||||
type ValueUnsetError struct {
|
||||
requestedValue string
|
||||
}
|
||||
|
||||
// Error implements the Error interface.
|
||||
func (s *StoreValueUnsetError) Error() string {
|
||||
func (s *ValueUnsetError) Error() string {
|
||||
return fmt.Sprintf("store: requested value not set: %s", s.requestedValue)
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func testBasic(t *testing.T) {
|
||||
|
||||
_, err = store.Get("invalid:key")
|
||||
assert.Error(err)
|
||||
var unsetErr *StoreValueUnsetError
|
||||
var unsetErr *ValueUnsetError
|
||||
assert.ErrorAs(err, &unsetErr)
|
||||
assert.NoError(store.Delete("test:input"))
|
||||
assert.NoError(store.Delete("another:input"))
|
||||
|
@ -107,7 +107,7 @@ func (s StoreWrapper) GetPeers() ([]peer.Peer, error) {
|
||||
// Should be called in a transaction together with Add/Remove operation(s).
|
||||
func (s StoreWrapper) IncrementPeersResourceVersion() error {
|
||||
val, err := s.GetPeersResourceVersion()
|
||||
var unsetErr *store.StoreValueUnsetError
|
||||
var unsetErr *store.ValueUnsetError
|
||||
if errors.As(err, &unsetErr) {
|
||||
val = 0
|
||||
} else if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user