Skip to content

The best way to handle exception #24

Closed

Description

@FebriPratama

Hello
Im using longpolling to get messages,

net core 3.1
Telegram.BotAPI version 6.6.1

public void StartPolling() { var updates = Bot.GetUpdates<IEnumerable<Update>>(); while (true) { if (updates.Any()) { foreach (var update in updates) { var botInstance = new SidomarBotService(_Token, _configuration); botInstance.OnUpdate(update); } var offset = updates.Last().UpdateId + 1; updates = Bot.GetUpdates<IEnumerable<Update>>(offset); } else { updates = Bot.GetUpdates<IEnumerable<Update>>(); } } }

Whats the best way to handle exception throws by startpolling error such as :

Screenshot 2023-04-17 084604

Activity

  1. Eptagone commented on Apr 18, 2023

    @Eptagone
    Owner

    Hello.

    Mmm, i think a try-catch inside your while statement should be enough for exceptions handling during getting updates.

  2. Repository owner locked and limited conversation to collaborators on Mar 4, 2025
  3. converted this issue into a discussion #52 on Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions