From db5067c0555fafbb35c9126765dab28af9b20d7c Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sun, 3 Nov 2024 14:16:26 -0500 Subject: [PATCH] Change error name --- pkg/nexus/commands.go | 2 +- pkg/talkgroups/cache.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/nexus/commands.go b/pkg/nexus/commands.go index 6842d83..a14a9ba 100644 --- a/pkg/nexus/commands.go +++ b/pkg/nexus/commands.go @@ -62,7 +62,7 @@ func (c *client) SendError(cmd *pb.Command, err error) { func (c *client) Talkgroup(ctx context.Context, tg *pb.Talkgroup) error { tgi, err := talkgroups.StoreFrom(ctx).TG(ctx, talkgroups.TG(tg.System, tg.Talkgroup)) if err != nil { - if err != talkgroups.ErrNoTG { + if err != talkgroups.ErrNotFound { log.Error().Err(err).Int32("sys", tg.System).Int32("tg", tg.Talkgroup).Msg("get talkgroup fail") } return err diff --git a/pkg/talkgroups/cache.go b/pkg/talkgroups/cache.go index f1c29fc..1ab4ed8 100644 --- a/pkg/talkgroups/cache.go +++ b/pkg/talkgroups/cache.go @@ -143,7 +143,7 @@ func (t *cache) Load(ctx context.Context, tgs []int64) error { return nil } -var ErrNoTG = errors.New("talkgroup not found") +var ErrNotFound = errors.New("talkgroup not found") func (t *cache) TG(ctx context.Context, tg ID) (Talkgroup, error) { t.RLock() @@ -158,20 +158,20 @@ func (t *cache) TG(ctx context.Context, tg ID) (Talkgroup, error) { switch err { case nil: case pgx.ErrNoRows: - return Talkgroup{}, ErrNoTG + return Talkgroup{}, ErrNotFound default: log.Error().Err(err).Msg("TG() cache add db get") - return Talkgroup{}, errors.Join(ErrNoTG, err) + return Talkgroup{}, errors.Join(ErrNotFound, err) } if len(recs) < 1 { - return Talkgroup{}, ErrNoTG + return Talkgroup{}, ErrNotFound } err = t.add(rowToTalkgroup(recs[0])) if err != nil { log.Error().Err(err).Msg("TG() cache add") - return rowToTalkgroup(recs[0]), errors.Join(ErrNoTG, err) + return rowToTalkgroup(recs[0]), errors.Join(ErrNotFound, err) } return rowToTalkgroup(recs[0]), nil