mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-14 00:37:27 -06:00
[bugfix] Rework MultiError to wrap + unwrap errors properly (#2057)
* rework multierror a bit * test multierror
This commit is contained in:
parent
2cee8f2dd8
commit
e8a20f587c
24 changed files with 263 additions and 154 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue