Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b766f6

Browse files
committed
improve errors handling
1 parent a7fec66 commit 8b766f6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

coderd/notifications/notifier.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
)
2929

3030
var (
31-
errFetchfailed = xerrors.New("failed to fetch helpers")
31+
errDecorateHelpersFailed = xerrors.New("failed to decorate helpers")
3232
)
3333

3434
// notifier is a consumer of the notifications_messages queue. It dequeues messages from that table and processes them
@@ -167,12 +167,7 @@ func (n *notifier) process(ctx context.Context, success chan<- dispatchResult, f
167167
deliverFn, err := n.prepare(ctx, msg)
168168
if err != nil {
169169
n.log.Warn(ctx, "dispatcher construction failed", slog.F("msg_id", msg.ID), slog.Error(err))
170-
if xerrors.Is(err, errFetchfailed) {
171-
failure <- n.newFailedDispatch(msg, err, true)
172-
} else {
173-
failure <- n.newFailedDispatch(msg, err, false)
174-
}
175-
170+
failure <- n.newFailedDispatch(msg, err, xerrors.Is(err, errDecorateHelpersFailed))
176171
n.metrics.PendingUpdates.Set(float64(len(success) + len(failure)))
177172
continue
178173
}
@@ -233,7 +228,7 @@ func (n *notifier) prepare(ctx context.Context, msg database.AcquireNotification
233228

234229
helpers, err := n.fetchHelpers(ctx)
235230
if err != nil {
236-
return nil, errFetchfailed
231+
return nil, errDecorateHelpersFailed
237232
}
238233

239234
var title, body string

0 commit comments

Comments
 (0)