Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi committed Oct 21, 2021
1 parent 87fc7b0 commit d2f9a52
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/group/internal/orm/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/group/internal/orm/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions x/group/internal/orm/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/group/internal/orm/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions x/group/internal/orm/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions x/group/internal/orm/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d2f9a52

Please sign in to comment.