From 9b3af14ef4dbf3f464a6dceb4aa04130433219c9 Mon Sep 17 00:00:00 2001 From: Dzyanis Kuzmenka Date: Thu, 17 Mar 2022 01:27:17 +0300 Subject: [PATCH] tencentcloud json marshaling err handling --- provider/tencentcloud/tencentcloud.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/provider/tencentcloud/tencentcloud.go b/provider/tencentcloud/tencentcloud.go index 283bd74..0a01de7 100644 --- a/provider/tencentcloud/tencentcloud.go +++ b/provider/tencentcloud/tencentcloud.go @@ -56,7 +56,6 @@ func truncateString(str string, num int) string { } func (tencentcloud *TencentCloud) Send(message sachet.Message) error { - var err error = nil switch message.Type { case "", "text": request := sms.NewSendSmsRequest() @@ -75,8 +74,12 @@ func (tencentcloud *TencentCloud) Send(message sachet.Message) error { fmt.Printf("An API error has returned: %s", err) return err } - b, _ := json.Marshal(response.Response) + b, err := json.Marshal(response.Response) + if err != nil { + return err + } fmt.Printf("%s", b) } - return err + + return nil }