mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Stop suppressing exceptions by early-exiting in finally (#5673)
* Stop suppressing exceptions in entrypoints due to sys.exit in finally * Remove returns in finally in Modlog API as well...
This commit is contained in:
parent
02c0328002
commit
6cb2378e2e
@ -286,7 +286,6 @@ def early_exit_runner(
|
|||||||
asyncio.set_event_loop(None)
|
asyncio.set_event_loop(None)
|
||||||
loop.stop()
|
loop.stop()
|
||||||
loop.close()
|
loop.close()
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
async def run_bot(red: Red, cli_flags: Namespace) -> None:
|
async def run_bot(red: Red, cli_flags: Namespace) -> None:
|
||||||
|
|||||||
@ -424,15 +424,13 @@ class Case:
|
|||||||
self.guild.id,
|
self.guild.id,
|
||||||
)
|
)
|
||||||
await self.edit({"message": None})
|
await self.edit({"message": None})
|
||||||
except Exception: # `finally` with `return` suppresses unexpected exceptions
|
except Exception:
|
||||||
log.exception(
|
log.exception(
|
||||||
"Modlog failed to edit the Discord message for"
|
"Modlog failed to edit the Discord message for"
|
||||||
" the case #%s from guild with ID %s due to unexpected error.",
|
" the case #%s from guild with ID %s due to unexpected error.",
|
||||||
self.case_number,
|
self.case_number,
|
||||||
self.guild.id,
|
self.guild.id,
|
||||||
)
|
)
|
||||||
finally:
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def message_content(self, embed: bool = True):
|
async def message_content(self, embed: bool = True):
|
||||||
"""
|
"""
|
||||||
@ -1071,14 +1069,13 @@ async def create_case(
|
|||||||
"Modlog failed to edit the Discord message for"
|
"Modlog failed to edit the Discord message for"
|
||||||
" the case #%s from guild with ID due to missing permissions."
|
" the case #%s from guild with ID due to missing permissions."
|
||||||
)
|
)
|
||||||
except Exception: # `finally` with `return` suppresses unexpected exceptions
|
except Exception:
|
||||||
log.exception(
|
log.exception(
|
||||||
"Modlog failed to send the Discord message for"
|
"Modlog failed to send the Discord message for"
|
||||||
" the case #%s from guild with ID %s due to unexpected error.",
|
" the case #%s from guild with ID %s due to unexpected error.",
|
||||||
case.case_number,
|
case.case_number,
|
||||||
case.guild.id,
|
case.guild.id,
|
||||||
)
|
)
|
||||||
finally:
|
|
||||||
return case
|
return case
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user