]> git.giacomolli.uk - onechat/blobdiff - telegram.go
Return known failures without redundant checks
[onechat] / telegram.go
index 306f8f5ab293a438da20411250b92ba21c4334d2..3d676d6961955c2d86c0b63d20c9046d7fcc0d89 100644 (file)
@@ -264,7 +264,7 @@ func (b *TelegramBot) send(ctx context.Context) {
 func (b *TelegramBot) poll(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp) error {
        offset, err := telegramLoadOffset(b.offsetPath)
        if err != nil {
-               return err
+               return fmt.Errorf("load Telegram offset: %w", err)
        }
 
        outage := &TelegramOutage{
@@ -313,7 +313,7 @@ poll:
                                        continue poll
                                }
 
-                               return err
+                               return fmt.Errorf("handle Telegram update: %w", err)
                        }
 
                        imageOutage.End()
@@ -323,7 +323,7 @@ poll:
                        offset = update.UpdateID + 1
                        err = telegramSaveOffset(b.offsetPath, offset)
                        if err != nil {
-                               return err
+                               return fmt.Errorf("save Telegram offset: %w", err)
                        }
                }
        }
@@ -476,7 +476,7 @@ func (b *TelegramBot) handle(ctx context.Context, l *TurnLoop, whatsapp *WhatsAp
        default:
                _, err := l.Submit(telegramSource, message.Text)
                if err != nil {
-                       return err
+                       return fmt.Errorf("submit Telegram text: %w", err)
                }
 
                err = l.Flush(context.WithoutCancel(ctx))