[chore] improve errors returned fetching account/statues from DB (#1084)
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
5d55e8d920
commit
2eea3d57e0
|
@ -21,6 +21,7 @@ package bundb
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -168,7 +169,7 @@ func (a *accountDB) getAccount(ctx context.Context, lookup string, dbQuery func(
|
||||||
// Set the account's related emojis
|
// Set the account's related emojis
|
||||||
account.Emojis, err = a.emojis.emojisFromIDs(ctx, account.EmojiIDs)
|
account.Emojis, err = a.emojis.emojisFromIDs(ctx, account.EmojiIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error getting account emojis: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"codeberg.org/gruf/go-cache/v3/result"
|
"codeberg.org/gruf/go-cache/v3/result"
|
||||||
|
@ -120,7 +121,7 @@ func (s *statusDB) getStatus(ctx context.Context, lookup string, dbQuery func(*g
|
||||||
|
|
||||||
if status.InReplyToID != "" {
|
if status.InReplyToID != "" {
|
||||||
// Also load in-reply-to status
|
// Also load in-reply-to status
|
||||||
status.InReplyTo = >smodel.Status{}
|
status.InReplyTo = new(gtsmodel.Status)
|
||||||
err := s.conn.NewSelect().Model(status.InReplyTo).
|
err := s.conn.NewSelect().Model(status.InReplyTo).
|
||||||
Where("? = ?", bun.Ident("status.id"), status.InReplyToID).
|
Where("? = ?", bun.Ident("status.id"), status.InReplyToID).
|
||||||
Scan(ctx)
|
Scan(ctx)
|
||||||
|
@ -131,7 +132,7 @@ func (s *statusDB) getStatus(ctx context.Context, lookup string, dbQuery func(*g
|
||||||
|
|
||||||
if status.BoostOfID != "" {
|
if status.BoostOfID != "" {
|
||||||
// Also load original boosted status
|
// Also load original boosted status
|
||||||
status.BoostOf = >smodel.Status{}
|
status.BoostOf = new(gtsmodel.Status)
|
||||||
err := s.conn.NewSelect().Model(status.BoostOf).
|
err := s.conn.NewSelect().Model(status.BoostOf).
|
||||||
Where("? = ?", bun.Ident("status.id"), status.BoostOfID).
|
Where("? = ?", bun.Ident("status.id"), status.BoostOfID).
|
||||||
Scan(ctx)
|
Scan(ctx)
|
||||||
|
@ -150,14 +151,14 @@ func (s *statusDB) getStatus(ctx context.Context, lookup string, dbQuery func(*g
|
||||||
// Set the status author account
|
// Set the status author account
|
||||||
status.Account, err = s.accounts.GetAccountByID(ctx, status.AccountID)
|
status.Account, err = s.accounts.GetAccountByID(ctx, status.AccountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error getting status account: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if id := status.BoostOfAccountID; id != "" {
|
if id := status.BoostOfAccountID; id != "" {
|
||||||
// Set boost of status' author account
|
// Set boost of status' author account
|
||||||
status.BoostOfAccount, err = s.accounts.GetAccountByID(ctx, id)
|
status.BoostOfAccount, err = s.accounts.GetAccountByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error getting boosted status account: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +166,7 @@ func (s *statusDB) getStatus(ctx context.Context, lookup string, dbQuery func(*g
|
||||||
// Set in-reply-to status' author account
|
// Set in-reply-to status' author account
|
||||||
status.InReplyToAccount, err = s.accounts.GetAccountByID(ctx, id)
|
status.InReplyToAccount, err = s.accounts.GetAccountByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error getting in reply to status account: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ func (s *statusDB) getStatus(ctx context.Context, lookup string, dbQuery func(*g
|
||||||
// Fetch status emojis
|
// Fetch status emojis
|
||||||
status.Emojis, err = s.emojis.emojisFromIDs(ctx, status.EmojiIDs)
|
status.Emojis, err = s.emojis.emojisFromIDs(ctx, status.EmojiIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error getting status emojis: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +182,7 @@ func (s *statusDB) getStatus(ctx context.Context, lookup string, dbQuery func(*g
|
||||||
// Fetch status mentions
|
// Fetch status mentions
|
||||||
status.Mentions, err = s.mentions.GetMentions(ctx, status.MentionIDs)
|
status.Mentions, err = s.mentions.GetMentions(ctx, status.MentionIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error getting status mentions: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue