Skip to content

Commit

Permalink
Fix: API exceptions weren't logged
Browse files Browse the repository at this point in the history
  • Loading branch information
DUB1401 committed Sep 27, 2023
1 parent f791e8f commit 35cd0a1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Source/Open.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
# Выжидание интервала.
Expand All @@ -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

Expand Down

0 comments on commit 35cd0a1

Please sign in to comment.