missing error handling #539
@@ -154,7 +154,7 @@ func (s *Service) onTelegramUpdate(ctx context.Context, update *model.TelegramWe
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if pending == nil {
|
if pending == nil {
|
||||||
s.logger.Info("Telegram confirmation reply dropped",
|
s.logger.Warn("Telegram confirmation reply dropped",
|
||||||
append(replyFields,
|
append(replyFields,
|
||||||
zap.String("outcome", "dropped"),
|
zap.String("outcome", "dropped"),
|
||||||
zap.String("reason", "no_pending_confirmation"),
|
zap.String("reason", "no_pending_confirmation"),
|
||||||
@@ -187,7 +187,7 @@ func (s *Service) onTelegramUpdate(ctx context.Context, update *model.TelegramWe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.TrimSpace(message.ChatID) != strings.TrimSpace(pending.TargetChatID) {
|
if strings.TrimSpace(message.ChatID) != strings.TrimSpace(pending.TargetChatID) {
|
||||||
s.logger.Info("Telegram confirmation reply dropped",
|
s.logger.Warn("Telegram confirmation reply dropped",
|
||||||
append(replyFields,
|
append(replyFields,
|
||||||
zap.String("outcome", "dropped"),
|
zap.String("outcome", "dropped"),
|
||||||
zap.String("reason", "chat_mismatch"),
|
zap.String("reason", "chat_mismatch"),
|
||||||
@@ -206,12 +206,14 @@ func (s *Service) onTelegramUpdate(ctx context.Context, update *model.TelegramWe
|
|||||||
if err := s.publishPendingConfirmationResult(pending, result); err != nil {
|
if err := s.publishPendingConfirmationResult(pending, result); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_ = s.sendTelegramText(ctx, &model.TelegramTextRequest{
|
if e := s.sendTelegramText(ctx, &model.TelegramTextRequest{
|
||||||
RequestID: pending.RequestID,
|
RequestID: pending.RequestID,
|
||||||
ChatID: pending.TargetChatID,
|
ChatID: pending.TargetChatID,
|
||||||
ReplyToMessageID: message.MessageID,
|
ReplyToMessageID: message.MessageID,
|
||||||
Text: "Only approved users can confirm this payment.",
|
Text: "Only approved users can confirm this payment.",
|
||||||
})
|
}); e != nil {
|
||||||
|
s.logger.Warn("Failed to create telegram text", append(replyFields, zap.Error(err))...)
|
||||||
|
}
|
||||||
if err := s.clearPendingConfirmation(ctx, pending.RequestID); err != nil {
|
if err := s.clearPendingConfirmation(ctx, pending.RequestID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -229,13 +231,15 @@ func (s *Service) onTelegramUpdate(ctx context.Context, update *model.TelegramWe
|
|||||||
if markErr := s.repo.PendingConfirmations().MarkClarified(ctx, pending.RequestID); markErr != nil {
|
if markErr := s.repo.PendingConfirmations().MarkClarified(ctx, pending.RequestID); markErr != nil {
|
||||||
s.logger.Warn("Failed to mark confirmation as clarified", zap.Error(markErr), zap.String("request_id", pending.RequestID))
|
s.logger.Warn("Failed to mark confirmation as clarified", zap.Error(markErr), zap.String("request_id", pending.RequestID))
|
||||||
}
|
}
|
||||||
_ = s.sendTelegramText(ctx, &model.TelegramTextRequest{
|
if e := s.sendTelegramText(ctx, &model.TelegramTextRequest{
|
||||||
RequestID: pending.RequestID,
|
RequestID: pending.RequestID,
|
||||||
ChatID: pending.TargetChatID,
|
ChatID: pending.TargetChatID,
|
||||||
ReplyToMessageID: message.MessageID,
|
ReplyToMessageID: message.MessageID,
|
||||||
Text: clarificationMessage(reason),
|
Text: clarificationMessage(reason),
|
||||||
})
|
}); e != nil {
|
||||||
s.logger.Info("Telegram confirmation reply dropped",
|
s.logger.Warn("Failed to create telegram text", append(replyFields, zap.Error(err))...)
|
||||||
|
}
|
||||||
|
s.logger.Warn("Telegram confirmation reply dropped",
|
||||||
append(replyFields,
|
append(replyFields,
|
||||||
zap.String("outcome", "dropped"),
|
zap.String("outcome", "dropped"),
|
||||||
zap.String("reason", "invalid_reply_format"),
|
zap.String("reason", "invalid_reply_format"),
|
||||||
|
|||||||
Reference in New Issue
Block a user