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:
commit
a3a55e7393
@ -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)
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user