capture stderr on good calculations

This commit is contained in:
xeals 2023-04-27 12:28:09 +10:00
parent ea2285ed1d
commit ce70a9fb4d
Signed by: xeals
GPG Key ID: A498C7AF27EC6B5C

5
bot.py
View File

@ -101,8 +101,11 @@ class BotClient(discord.Client):
proc = sp.run( proc = sp.run(
["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE ["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE
) )
stderr = proc.stderr.decode().strip()
if proc.returncode != 0: if proc.returncode != 0:
raise Exception(proc.stderr.decode()) raise Exception(stderr)
if stderr:
_log.warning(f"running calculation '{args}': {stderr}")
return proc.stdout.decode() return proc.stdout.decode()
def is_replay(self, message: discord.Message) -> bool: def is_replay(self, message: discord.Message) -> bool: