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

Extend exception handler behaviour with middlewares

This commit is contained in:
_run 2022-07-11 23:22:11 +05:00
parent e689e968db
commit 124606fdcb
2 changed files with 8 additions and 10 deletions

View File

@ -3964,11 +3964,10 @@ class TeleBot:
except Exception as e:
handler_error = e
if not middlewares:
if self.exception_handler:
return self.exception_handler.handle(e)
logging.error(str(e))
return
if self.exception_handler:
self.exception_handler.handle(e)
else: logging.error(str(e))
if middlewares:
for middleware in middlewares:
middleware.post_process(message, data, handler_error)

View File

@ -319,11 +319,10 @@ class AsyncTeleBot:
except Exception as e:
handler_error = e
if not middlewares:
if self.exception_handler:
return self.exception_handler.handle(e)
logging.error(str(e))
return
if self.exception_handler:
self.exception_handler.handle(e)
else: logging.error(str(e))
if middlewares:
for middleware in middlewares: