Skip to content

Commit

Permalink
chore(kv): wrap error using func instead of defer in index
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeMac committed Mar 16, 2020
1 parent 95d334f commit 671e0e3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kv/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,20 @@ func (i *IndexMigration) Name() string {

// Up initializes the index bucket and populates the index.
func (i *IndexMigration) Up(ctx context.Context, store Store) (err error) {
defer func() {
if err != nil {
err = fmt.Errorf("migration (up) %s: %w", i.Name(), err)
wrapErr := func(err error) error {
if err == nil {
return nil
}
}()

return fmt.Errorf("migration (up) %s: %w", i.Name(), err)
}

if err = i.initialize(ctx, store); err != nil {
return err
return wrapErr(err)
}

_, err = i.Populate(ctx, store, i.opts...)
return err
return wrapErr(err)
}

// Down deletes all entries from the index.
Expand Down

0 comments on commit 671e0e3

Please sign in to comment.