mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -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
|
||||
"""
|
||||
msg = context.get("exception", context["message"])
|
||||
exc = context.get("exception")
|
||||
# These will get handled later when it *also* kills loop.run_forever
|
||||
if not isinstance(msg, (KeyboardInterrupt, SystemExit)):
|
||||
if isinstance(msg, Exception):
|
||||
log.critical("Caught unhandled exception in task:\n", exc_info=msg)
|
||||
else:
|
||||
log.critical("Caught unhandled exception in task: %s", msg)
|
||||
if exc is not None and isinstance(exc, (KeyboardInterrupt, SystemExit)):
|
||||
return
|
||||
# Maybe in the future we should handle some of the other things
|
||||
# that the default exception handler handles, but this should work fine for now.
|
||||
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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user