Skip to content

Commit

Permalink
remove odd way to create error
Browse files Browse the repository at this point in the history
  • Loading branch information
dzyanis committed Mar 16, 2022
1 parent 7f95f61 commit 61399cc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions provider/aliyun/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func NewAliyun(config Config) (*Aliyun, error) {
}

func (aliyun *Aliyun) Send(message sachet.Message) error {
var err error = nil
switch message.Type {
case "", "text":
request := dysmsapi.CreateSendSmsRequest()
Expand All @@ -52,11 +51,12 @@ func (aliyun *Aliyun) Send(message sachet.Message) error {
var response *dysmsapi.SendSmsResponse
response, err = aliyun.client.SendSms(request)
if err == nil && (!response.IsSuccess() || response.Code != "OK") {
err = fmt.Errorf(response.String())
return fmt.Errorf(response.String())
}
}
default:
return fmt.Errorf("unknown message type %s", message.Type)
}
return err

return nil
}
3 changes: 1 addition & 2 deletions provider/messagebird/messagebird.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func NewMessageBird(config Config) *MessageBird {
}
}

func (mb *MessageBird) Send(message sachet.Message) error {
var err error = nil
func (mb *MessageBird) Send(message sachet.Message) (err error) {
switch message.Type {
case "", "text":
_, err = sms.Create(mb.client, message.From, message.To, message.Text, &mb.messageParams)
Expand Down
1 change: 0 additions & 1 deletion provider/pushbullet/pushbullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (c *Pushbullet) Send(message sachet.Message) error {
default:
return fmt.Errorf("unrecognised target type: %s", targetType)
}

}

return nil
Expand Down
3 changes: 1 addition & 2 deletions provider/textmagic/textmagic.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func NewTextMagic(config Config) *TextMagic {
}
}

func (tm *TextMagic) Send(message sachet.Message) error {
var err error = nil
func (tm *TextMagic) Send(message sachet.Message) (err error) {
switch message.Type {
case "", "text":
joinedTo := strings.Join(message.To[:], ",")
Expand Down

0 comments on commit 61399cc

Please sign in to comment.