From b27b5ea64a3e0dd465612913b0029c45e77eb012 Mon Sep 17 00:00:00 2001 From: Rahiel Kasim Date: Mon, 8 May 2017 20:51:12 +0200 Subject: [PATCH] Updated Exception Handling (markdown) --- Exception-Handling.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Exception-Handling.md b/Exception-Handling.md index 7ccf28b..415bad0 100644 --- a/Exception-Handling.md +++ b/Exception-Handling.md @@ -1,6 +1,6 @@ In `python-telegram-bot`, all Telegram-related errors are encapsulated in the `TelegramError` exception class and its subclasses. -To simplify error handling, any `TelegramError` that is raised in one of your handlers (or while calling `getUpdates` in the `Updater`) is forwarded to all registered error handlers, so you can react to them. You can register an error handler by calling `Dispatcher.add_error_handler(callback)`, where `callback` is a function that takes the arguments `bot, update, error`. `update` will be the update that caused the error and `error` the `TelegramError` that was raised. +To simplify error handling, any `TelegramError` that is raised in one of your handlers (or while calling `get_updates` in the `Updater`) is forwarded to all registered error handlers, so you can react to them. You can register an error handler by calling `Dispatcher.add_error_handler(callback)`, where `callback` is a function that takes the arguments `bot, update, error`. `update` will be the update that caused the error and `error` the `TelegramError` that was raised. Example: You're trying to send a message, but the user blocked the bot. An `Unauthorized` exception, a subclass of `TelegramError`, will be raised and delivered to your error handler, so you can delete it from your conversation list, if you keep one. @@ -34,23 +34,23 @@ dispatcher.add_error_handler(error_callback) Here are some examples that would cause a `BadRequest` error to be raised: ```python ->>> bot.leaveChat(chat_id=) +>>> bot.leave_chat(chat_id=) [...] telegram.error.BadRequest: Chat not found ->>> bot.answerCallbackQuery() +>>> bot.answer_callback_query() [...] telegram.error.BadRequest: Query_id_invalid ->>> bot.getFile() +>>> bot.get_file() [...] telegram.error.BadRequest: Invalid file id ->>> bot.editMessageText(chat_id, "sample old message") +>>> bot.edit_message_text(chat_id, "sample old message") [...] telegram.error.BadRequest: Message is not modified ->>> bot.sendMessage(chat_id, 'a'*40960) +>>> bot.send_message(chat_id, 'a'*40960) [...] telegram.error.BadRequest: Message is too long ```