Skip to content

Commit

Permalink
fix: Add error logging for creating flex message and pushing message
Browse files Browse the repository at this point in the history
  • Loading branch information
peterxcli committed Feb 27, 2024
1 parent 006691b commit 4f37b4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/worker/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"context"
"encoding/json"
"fmt"
"log"

"github.com/hibiken/asynq"
"github.com/line/line-bot-sdk-go/linebot"
"github.com/redis/go-redis/v9"
"log"
)

const (
Expand Down Expand Up @@ -48,6 +49,7 @@ func (eth *EventTaskHandler) HandleEventTask(ctx context.Context, t *asynq.Task)
var message linebot.SendingMessage
flexContainer, err := line_utils.CreateFlexMessage(&eventDetails)
if err != nil {
log.Println("Error creating flex message", err)
message = linebot.NewTextMessage(fmt.Sprintf("Event: %s, 即將開始", eventDetails.Name))
} else {
message = linebot.NewFlexMessage(fmt.Sprintf("Event: %s, 即將開始", eventDetails.Name), *flexContainer)
Expand All @@ -57,7 +59,7 @@ func (eth *EventTaskHandler) HandleEventTask(ctx context.Context, t *asynq.Task)

_, err = eth.bot.PushMessage(p.UserID, message).Do()
if err != nil {
log.Println(err)
log.Println("Error pushing message", err)
return err
}

Expand Down

0 comments on commit 4f37b4a

Please sign in to comment.