Exceptions

Example:

import asyncio
from aiotgm.types import Message
from aiotgm import Client, TelegramError

bot = Client('<your_api_token>')

@bot.manage_message()
async def foo(msg: Message):
    try:
        await bot.send_message(msg.chat.id, "Hello my friend.")
    except (TelegramError, TimeoutError) as e:
        print(e)
exception apitele.TelegramError(error_code, description)[source]

Bases: Exception

Class to handle unsuccessful requests to the Telegram Bot API Server.

Parameters:
  • error_code (int) – The status code of the unsuccessful request.

  • description (str) – Description of why the request was unsuccessful.

exception TimeoutError

This error is raised when a request is not returned in 5 minutes.