From 35cd0a170bf2448a27d0b89dff379b99cd2a4f69 Mon Sep 17 00:00:00 2001 From: DUB1401 Date: Wed, 27 Sep 2023 18:49:34 +0300 Subject: [PATCH] Fix: API exceptions weren't logged --- Source/Open.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Open.py b/Source/Open.py index faceca8..a05d43b 100644 --- a/Source/Open.py +++ b/Source/Open.py @@ -3,9 +3,9 @@ from Source.Configurator import Configurator from MessageEditor import MessageEditor from vk_captcha import VkCaptchaSolver -from vk_api import VkApi, exceptions from threading import Thread, Timer from Source.Functions import * +from vk_api import VkApi from time import sleep import telebot @@ -37,7 +37,7 @@ def __Authorizate(self): if self.__Settings["vk-access-token"] == None: self.__Session.auth(token_only = True) - except exceptions.AuthError as ExceptionData: + except VkApi.exceptions.AuthError as ExceptionData: # Запись в лог ошибки: исключение авторизации. logging.error("[Open API] Authorization exception: " + str(ExceptionData).split(" Please")[0]) # Выжидание интервала. @@ -55,7 +55,15 @@ def __GetPosts(self, WallID: str, PostsCount: int = 20, Offset: int = 0) -> list # Добавление минуса к ID стены. WallID = "-" + str(WallID).strip("-") # Список полученных постов. - WallPosts = self.__API.wall.get(owner_id = WallID, count = PostsCount, offset = Offset)["items"] + WallPosts = list() + + try: + # Попытка получить список постов. + WallPosts = self.__API.wall.get(owner_id = WallID, count = PostsCount, offset = Offset)["items"] + + except VkApi.exceptions.ApiError as ExceptionData: + # Запись в лог ошибки: исключение API. + logging.error("[Open API] Exception: " + str(ExceptionData)) return WallPosts