1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1617 from coder2020official/bugfixes

Extended exception handler behaviour with middlewares for synchronous version as well
This commit is contained in:
Badiboy 2022-07-12 22:12:20 +03:00 committed by GitHub
commit a3a55e7393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -4126,12 +4126,10 @@ class TeleBot:
except Exception as e: except Exception as e:
handler_error = e handler_error = e
if not middlewares:
if self.exception_handler: if self.exception_handler:
return self.exception_handler.handle(e) self.exception_handler.handle(e)
logging.error(str(e)) else: logging.error(str(e))
return
# remove the bot from data
if middlewares: if middlewares:
for middleware in middlewares: for middleware in middlewares:
middleware.post_process(message, data, handler_error) middleware.post_process(message, data, handler_error)

View File

@ -352,6 +352,7 @@ class AsyncTeleBot:
self.exception_handler.handle(e) self.exception_handler.handle(e)
else: logger.error(str(e)) else: logger.error(str(e))
if middlewares: if middlewares:
for middleware in middlewares: for middleware in middlewares:
await middleware.post_process(message, data, handler_error) await middleware.post_process(message, data, handler_error)