diff options
author | 2023-08-02 17:21:46 +0200 | |
---|---|---|
committer | 2023-08-02 17:21:46 +0200 | |
commit | e8a20f587c0b0129bc68f5c6092c54f2b4c3519a (patch) | |
tree | 3677b4abec2cabf3b5042115ba76505daf5fddf3 /internal/db/bundb/instance.go | |
parent | [bugfix] fix slow accounts / statuses using emojis lookups (#2056) (diff) | |
download | gotosocial-e8a20f587c0b0129bc68f5c6092c54f2b4c3519a.tar.xz |
[bugfix] Rework MultiError to wrap + unwrap errors properly (#2057)
* rework multierror a bit
* test multierror
Diffstat (limited to 'internal/db/bundb/instance.go')
-rw-r--r-- | internal/db/bundb/instance.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/db/bundb/instance.go b/internal/db/bundb/instance.go index 48332c731..6657072fd 100644 --- a/internal/db/bundb/instance.go +++ b/internal/db/bundb/instance.go @@ -173,7 +173,7 @@ func (i *instanceDB) getInstance(ctx context.Context, lookup string, dbQuery fun func (i *instanceDB) populateInstance(ctx context.Context, instance *gtsmodel.Instance) error { var ( err error - errs = make(gtserror.MultiError, 0, 2) + errs = gtserror.NewMultiError(2) ) if instance.DomainBlockID != "" && instance.DomainBlock == nil { @@ -183,7 +183,7 @@ func (i *instanceDB) populateInstance(ctx context.Context, instance *gtsmodel.In instance.Domain, ) if err != nil { - errs.Append(gtserror.Newf("error populating instance domain block: %w", err)) + errs.Appendf("error populating instance domain block: %w", err) } } @@ -194,11 +194,15 @@ func (i *instanceDB) populateInstance(ctx context.Context, instance *gtsmodel.In instance.ContactAccountID, ) if err != nil { - errs.Append(gtserror.Newf("error populating instance contact account: %w", err)) + errs.Appendf("error populating instance contact account: %w", err) } } - return errs.Combine() + if err := errs.Combine(); err != nil { + return gtserror.Newf("%w", err) + } + + return nil } func (i *instanceDB) PutInstance(ctx context.Context, instance *gtsmodel.Instance) error { |