exceptions test

This commit is contained in:
Kylmakalle 2017-07-06 00:51:41 +03:00
parent 43a617394a
commit 25e81c46df
2 changed files with 6 additions and 6 deletions

6
bot.py
View File

@ -582,7 +582,7 @@ def reply_sticker(message):
except Exception: except Exception:
bot.reply_to(message, '*Произошла неизвестная ошибка при отправке*', bot.reply_to(message, '*Произошла неизвестная ошибка при отправке*',
parse_mode='Markdown').wait() # TODO?: Bugreport system parse_mode='Markdown').wait() # TODO?: Bugreport system
logging.exception('Error: {}'.format(traceback.format_exc())) print('Error: {}'.format(traceback.format_exc()))
@bot.message_handler(content_types=['photo']) @bot.message_handler(content_types=['photo'])
@ -610,7 +610,7 @@ def reply_contact(message):
except Exception: except Exception:
bot.reply_to(message, '*Произошла неизвестная ошибка при отправке*', bot.reply_to(message, '*Произошла неизвестная ошибка при отправке*',
parse_mode='Markdown').wait() parse_mode='Markdown').wait()
logging.exception('Error: {}'.format(traceback.format_exc())) print('Error: {}'.format(traceback.format_exc()))
@bot.message_handler(content_types=['text']) @bot.message_handler(content_types=['text'])
@ -641,7 +641,7 @@ def reply_text(message):
except Exception: except Exception:
bot.reply_to(message, 'Произошла неизвестная ошибка при отправке', bot.reply_to(message, 'Произошла неизвестная ошибка при отправке',
parse_mode='Markdown').wait() parse_mode='Markdown').wait()
logging.exception('Error: {}'.format(traceback.format_exc())) print('Error: {}'.format(traceback.format_exc()))
# bot.polling(none_stop=True) # bot.polling(none_stop=True)

View File

@ -27,7 +27,7 @@ class VkPolling:
handle_updates(vk_user, bot, chat_id, updates) handle_updates(vk_user, bot, chat_id, updates)
except requests.exceptions.ReadTimeout: except requests.exceptions.ReadTimeout:
timeout *= 2 timeout *= 2
logging.warning('Retrying VK Polling in {} seconds.'.format(int(timeout / 10))) print('Retrying VK Polling in {} seconds.'.format(int(timeout / 10)))
for i in range(timeout): for i in range(timeout):
if self._running: if self._running:
time.sleep(0.1) time.sleep(0.1)
@ -283,9 +283,9 @@ class VkMessage:
api = vk.API(self.session) api = vk.API(self.session)
try: try:
new = api.messages.getLongPollHistory(ts=self.ts, pts=self.pts) new = api.messages.getLongPollHistory(ts=self.ts, pts=self.pts)
except: except vk.api.VkAPIError:
timeout = 3 timeout = 3
logging.warning('Retrying getLongPollHistory in {} seconds'.format(timeout)) print('Retrying getLongPollHistory in {} seconds'.format(timeout))
time.sleep(timeout) time.sleep(timeout)
self.ts, self.pts = get_tses(self.session) self.ts, self.pts = get_tses(self.session)
new = api.messages.getLongPollHistory(ts=self.ts, pts=self.pts) new = api.messages.getLongPollHistory(ts=self.ts, pts=self.pts)