Errors & Exceptions#
FTMGram translates MTProto RPC error codes into native Python exceptions inheriting from ftmgram.errors.RPCError.
Exception Hierarchy#
Exception |
Description |
|---|---|
|
Base class for all Telegram RPC errors. |
|
Raised when rate limits are exceeded. Contains |
|
Invalid parameters (e.g. |
|
Invalid authorization (e.g. |
|
Insufficient rights or user has blocked the bot ( |
|
Telegram server-side temporary outage. |
Handling FloodWait#
import asyncio
from ftmgram.errors import FloodWait
try:
await app.send_message(chat_id, "Hello")
except FloodWait as e:
print(f"Rate limited! Sleeping for {e.value}s")
await asyncio.sleep(e.value)
await app.send_message(chat_id, "Hello")