From 8996aee7fbd33d3412c92bf72c7cb5ae8ca028ab Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Wed, 3 May 2023 02:25:35 +0200 Subject: [PATCH] Fix shutdown handling failing when exit code is not ExitCodes instance (#6112) --- redbot/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/redbot/__main__.py b/redbot/__main__.py index b0fe289da..90a547cf5 100644 --- a/redbot/__main__.py +++ b/redbot/__main__.py @@ -525,7 +525,12 @@ def main(): # We also have to catch this one here. Basically any exception which normally # Kills the python interpreter (Base Exceptions minus asyncio.cancelled) # We need to do something with prior to having the loop close - log.info("Shutting down with exit code: %s (%s)", exc.code.value, exc.code.name) + exit_code = int(exc.code) + try: + exit_code_name = ExitCodes(exit_code).name + except ValueError: + exit_code_name = "UNKNOWN" + log.info("Shutting down with exit code: %s (%s)", exit_code, exit_code_name) if red is not None: loop.run_until_complete(shutdown_handler(red, None, exc.code)) except Exception as exc: # Non standard case.