Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kolkov committed Mar 3, 2021
1 parent 15d037b commit 3e33653
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ type SenderBrokenContactError struct {
SenderError error
}

func (e *SenderBrokenContactError) Error() string {
func NewSenderBrokenContactError(senderError error) SenderBrokenContactError {
return SenderBrokenContactError{
SenderError: senderError,
}
}

func (e SenderBrokenContactError) Error() string {
return e.SenderError.Error()
}
2 changes: 1 addition & 1 deletion senders/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (sender *Sender) sendMessage(message string, contact string, triggerID stri
errorText := err.Error()
if errorText == ErrorTextChannelArchived || errorText == ErrorTextNotInChannel ||
errorText == ErrorTextChannelNotFound {
return channelID, threadTimestamp, &moira.SenderBrokenContactError{SenderError: err}
return channelID, threadTimestamp, moira.NewSenderBrokenContactError(err)
}
return channelID, threadTimestamp, fmt.Errorf("failed to send %s event message to slack [%s]: %s",
triggerID, contact, errorText)
Expand Down
2 changes: 1 addition & 1 deletion senders/telegram/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (sender *Sender) sendAsMessage(chat *telebot.Chat, message string) error {
if e.Code == 401 || e.Code == 400 && (e.Message == telebot.ErrBlockedByUser.Message ||
e.Message == telebot.ErrEmptyChatID.Message ||
e.Message == telebot.ErrChatNotFound.Message) {
return &moira.SenderBrokenContactError{SenderError: e}
return moira.NewSenderBrokenContactError(err)
}
}
return fmt.Errorf("can't send event message [%s] to %v: %s", message, chat.ID, err.Error())
Expand Down

0 comments on commit 3e33653

Please sign in to comment.