Skip to content

Commit 037ea8b

Browse files
committed
add extra error field
1 parent 0da98d1 commit 037ea8b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/services/slack.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ func (s *slackService) Send(notification Notification, dest Destination) error {
178178
if err != nil {
179179
return err
180180
}
181+
client, err := newSlackClient(s.opts)
181182
return slackutil.NewThreadedClient(
182-
newSlackClient(s.opts, err),
183+
client,
184+
err,
183185
slackState,
184186
).SendMessage(
185187
context.TODO(),
@@ -196,7 +198,7 @@ func (s *slackService) GetSigningSecret() string {
196198
return s.opts.SigningSecret
197199
}
198200

199-
func newSlackClient(opts SlackOptions, err error) *slack.Client {
201+
func newSlackClient(opts SlackOptions) (slackclient *slack.Client, err error) {
200202
apiURL := slack.APIURL
201203
if opts.ApiURL != "" {
202204
apiURL = opts.ApiURL
@@ -209,7 +211,7 @@ func newSlackClient(opts SlackOptions, err error) *slack.Client {
209211
client := &http.Client{
210212
Transport: httputil.NewLoggingRoundTripper(transport, log.WithField("service", "slack")),
211213
}
212-
return slack.New(opts.Token, slack.OptionHTTPClient(client), slack.OptionAPIURL(apiURL))
214+
return slack.New(opts.Token, slack.OptionHTTPClient(client), slack.OptionAPIURL(apiURL)), err
213215
}
214216

215217
func isValidIconURL(iconURL string) bool {

pkg/util/slack/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ func NewState(limiter *rate.Limiter) *state {
8080

8181
type threadedClient struct {
8282
Client SlackClient
83+
error
8384
*state
8485
}
8586

86-
func NewThreadedClient(client SlackClient, s *state) *threadedClient {
87-
return &threadedClient{client, s}
87+
func NewThreadedClient(client SlackClient, err error, s *state) *threadedClient {
88+
return &threadedClient{client, err, s}
8889
}
8990

9091
func (c *threadedClient) getChannelID(recipient string) string {

pkg/util/slack/client_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func TestThreadedClient(t *testing.T) {
174174

175175
client := NewThreadedClient(
176176
m,
177+
slack.ErrExpiredTimestamp,
177178
&state{
178179
Limiter: rate.NewLimiter(rate.Inf, 1),
179180
ThreadTSs: tc.threadTSs,

0 commit comments

Comments
 (0)