mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Improve global exception handler log messages
* Merge pull request #4980 * Improve global exception handler log messages
This commit is contained in:
parent
e2f0ac582b
commit
356922f4de
@ -446,13 +446,18 @@ def global_exception_handler(red, loop, context):
|
|||||||
"""
|
"""
|
||||||
Logs unhandled exceptions in other tasks
|
Logs unhandled exceptions in other tasks
|
||||||
"""
|
"""
|
||||||
msg = context.get("exception", context["message"])
|
exc = context.get("exception")
|
||||||
# These will get handled later when it *also* kills loop.run_forever
|
# These will get handled later when it *also* kills loop.run_forever
|
||||||
if not isinstance(msg, (KeyboardInterrupt, SystemExit)):
|
if exc is not None and isinstance(exc, (KeyboardInterrupt, SystemExit)):
|
||||||
if isinstance(msg, Exception):
|
return
|
||||||
log.critical("Caught unhandled exception in task:\n", exc_info=msg)
|
# Maybe in the future we should handle some of the other things
|
||||||
else:
|
# that the default exception handler handles, but this should work fine for now.
|
||||||
log.critical("Caught unhandled exception in task: %s", msg)
|
log.critical(
|
||||||
|
"Caught unhandled exception in %s:\n%s",
|
||||||
|
context.get("future", "event loop"),
|
||||||
|
context["message"],
|
||||||
|
exc_info=exc,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def red_exception_handler(red, red_task: asyncio.Future):
|
def red_exception_handler(red, red_task: asyncio.Future):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user