diff --git a/types/errors/errors.go b/types/errors/errors.go index 7b1f6f4c34a7..29ba3195f146 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -157,23 +157,23 @@ var ( // ErrInvalidDecString defines an error for an invalid decimal string ErrInvalidDecString = Register(mathCodespace, 41, "invalid decimal string") - // ErrIteratorDone defines an error when an iterator is done - ErrIteratorDone = Register(ormCodespace, 42, "iterator done") + // ErrORMIteratorDone defines an error when an iterator is done + ErrORMIteratorDone = Register(ormCodespace, 42, "iterator done") - // ErrInvalidIterator defines an error for an invalid iterator - ErrInvalidIterator = Register(ormCodespace, 43, "invalid iterator") + // ErrORMInvalidIterator defines an error for an invalid iterator + ErrORMInvalidIterator = Register(ormCodespace, 43, "invalid iterator") - // ErrUniqueConstraint defines an error when a value already exists at a given key - ErrUniqueConstraint = Register(ormCodespace, 44, "unique constraint violation") + // ErrORMUniqueConstraint defines an error when a value already exists at a given key + ErrORMUniqueConstraint = Register(ormCodespace, 44, "unique constraint violation") - // ErrEmptyModel defines an error when an empty model is provided for building a table - ErrEmptyModel = Register(ormCodespace, 45, "invalid argument") + // ErrORMEmptyModel defines an error when an empty model is provided for building a table + ErrORMEmptyModel = Register(ormCodespace, 45, "invalid argument") - // ErrIndexKeyMaxLength defines an error when a key exceeds max length - ErrKeyMaxLength = Register(ormCodespace, 46, "index key exceeds max length") + // ErrORMKeyMaxLength defines an error when a key exceeds max length + ErrORMKeyMaxLength = Register(ormCodespace, 46, "index key exceeds max length") - // ErrEmptyModel defines an error for an empty key - ErrEmptyKey = Register(ormCodespace, 47, "cannot use empty key") + // ErrORMEmptyKey defines an error for an empty key + ErrORMEmptyKey = Register(ormCodespace, 47, "cannot use empty key") ) // Register returns an error instance that should be used as the base for diff --git a/x/group/internal/orm/sequence.go b/x/group/internal/orm/sequence.go index dbec3ee75b6b..a8d70f7243ac 100644 --- a/x/group/internal/orm/sequence.go +++ b/x/group/internal/orm/sequence.go @@ -55,7 +55,7 @@ func (s Sequence) PeekNextVal(store sdk.KVStore) uint64 { func (s Sequence) InitVal(store sdk.KVStore, seq uint64) error { pStore := prefix.NewStore(store, []byte{s.prefix}) if pStore.Has(sequenceStorageKey) { - return errors.Wrap(errors.ErrUniqueConstraint, "already initialized") + return errors.Wrap(errors.ErrORMUniqueConstraint, "already initialized") } pStore.Set(sequenceStorageKey, EncodeSequence(seq)) return nil diff --git a/x/group/internal/orm/sequence_test.go b/x/group/internal/orm/sequence_test.go index 5d3d256cf8e3..023f7318dae2 100644 --- a/x/group/internal/orm/sequence_test.go +++ b/x/group/internal/orm/sequence_test.go @@ -17,7 +17,7 @@ func TestSequenceUniqueConstraint(t *testing.T) { err := seq.InitVal(store, 2) require.NoError(t, err) err = seq.InitVal(store, 3) - require.True(t, errors.ErrUniqueConstraint.Is(err)) + require.True(t, errors.ErrORMUniqueConstraint.Is(err)) } func TestSequenceIncrements(t *testing.T) { diff --git a/x/group/internal/orm/table.go b/x/group/internal/orm/table.go index 5883640e0c3c..f3611850045e 100644 --- a/x/group/internal/orm/table.go +++ b/x/group/internal/orm/table.go @@ -32,7 +32,7 @@ type table struct { // newTable creates a new table func newTable(prefix [2]byte, model codec.ProtoMarshaler, cdc codec.Codec) (*table, error) { if model == nil { - return nil, errors.ErrEmptyModel.Wrap("Model must not be nil") + return nil, errors.ErrORMEmptyModel.Wrap("Model must not be nil") } tp := reflect.TypeOf(model) if tp.Kind() == reflect.Ptr { @@ -61,13 +61,13 @@ func (a *table) AddAfterDeleteInterceptor(interceptor AfterDeleteInterceptor) { } // Create persists the given object under the rowID key, returning an -// errors.ErrUniqueConstraint if a value already exists at that key. +// errors.ErrORMUniqueConstraint if a value already exists at that key. // // Create iterates through the registered callbacks that may add secondary index // keys. func (a table) Create(store sdk.KVStore, rowID RowID, obj codec.ProtoMarshaler) error { if a.Has(store, rowID) { - return errors.ErrUniqueConstraint + return errors.ErrORMUniqueConstraint } return a.Set(store, rowID, obj) @@ -94,7 +94,7 @@ func (a table) Update(store sdk.KVStore, rowID RowID, newValue codec.ProtoMarsha // keys. func (a table) Set(store sdk.KVStore, rowID RowID, newValue codec.ProtoMarshaler) error { if len(rowID) == 0 { - return errors.ErrEmptyKey + return errors.ErrORMEmptyKey } if err := assertCorrectType(a.model, newValue); err != nil { return err diff --git a/x/group/internal/orm/table_test.go b/x/group/internal/orm/table_test.go index 511a328ce5cf..aff91e22417e 100644 --- a/x/group/internal/orm/table_test.go +++ b/x/group/internal/orm/table_test.go @@ -62,7 +62,7 @@ func TestCreate(t *testing.T) { Id: 1, Name: "some name", }, - expErr: errors.ErrEmptyKey, + expErr: errors.ErrORMEmptyKey, }, "happy path": { rowID: EncodeSequence(1), diff --git a/x/group/internal/orm/types.go b/x/group/internal/orm/types.go index 35b1f0f4f5dd..48e2f631839d 100644 --- a/x/group/internal/orm/types.go +++ b/x/group/internal/orm/types.go @@ -30,7 +30,7 @@ type Validateable interface { // Iterator allows iteration through a sequence of key value pairs type Iterator interface { // LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there - // are no more items the ErrIteratorDone error is returned + // are no more items the ErrORMIteratorDone error is returned // The key is the rowID. LoadNext(dest codec.ProtoMarshaler) (RowID, error) // Close releases the iterator and should be called at the end of iteration @@ -59,7 +59,7 @@ type RowGetter func(store sdk.KVStore, rowID RowID, dest codec.ProtoMarshaler) e func NewTypeSafeRowGetter(prefixKey [2]byte, model reflect.Type, cdc codec.Codec) RowGetter { return func(store sdk.KVStore, rowID RowID, dest codec.ProtoMarshaler) error { if len(rowID) == 0 { - return errors.Wrap(errors.ErrEmptyKey, "key must not be nil") + return errors.Wrap(errors.ErrORMEmptyKey, "key must not be nil") } if err := assertCorrectType(model, dest); err != nil { return err diff --git a/x/group/internal/orm/types_test.go b/x/group/internal/orm/types_test.go index e5ef4ecf5ab1..bf8e3648c913 100644 --- a/x/group/internal/orm/types_test.go +++ b/x/group/internal/orm/types_test.go @@ -51,11 +51,11 @@ func TestTypeSafeRowGetter(t *testing.T) { "empty rowID not allowed": { srcRowID: []byte{}, srcModelType: reflect.TypeOf(testdata.TableModel{}), - expErr: errors.ErrEmptyKey, + expErr: errors.ErrORMEmptyKey, }, "nil rowID not allowed": { srcModelType: reflect.TypeOf(testdata.TableModel{}), - expErr: errors.ErrEmptyKey, + expErr: errors.ErrORMEmptyKey, }, } for msg, spec := range specs {