From 0ad7b297967e3d53043ae41c86002f5b707fba80 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 00:53:39 +0100 Subject: [PATCH] core/MMBot.py --- core/MMBot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/MMBot.py b/core/MMBot.py index 2d676d0..d51d6c7 100644 --- a/core/MMBot.py +++ b/core/MMBot.py @@ -304,11 +304,13 @@ class MMBot(): self.bot.debug_chan("do_POST(): Invalid command/unknown command.\n# :boom::boom::boom::boom::boom:\n```\n"+self.path+"\n```") self.respond_cmd_err("Invalid command/unknown command") - except: - self.bot.debug_chan("##### Error in module: ``"+repr(module)+"``\n# :boom::boom::boom::boom::boom:\n```\n"+traceback.format_exc()+"\n```") + # always try to fail to retain userinput. If previously responded to, nothing will happen. + self.respond(400, if_nonzero_secondary='ignore') - # always try to fail to retain userinput. If previously responded to, nothing will happen. - self.respond(400, if_nonzero_secondary='ignore') + except Exception as e: + self.bot.debug_chan("##### Exception in ``"+self.path.strip("/")+"``: ``"+repr(e)+"``\n# :boom::boom::boom::boom::boom:") + logger.exception("do_POST(): Exception in: %s\nRequest-data:%s", self.path.strip("/"), pprint.pformat(data)) + self.respond_cmd_err("A serverside error occured. You are likely not at fault. @someone should have been contacted.", http_code=500, if_nonzero_secondary='ignore') # Send a response to the channel. @@ -343,14 +345,14 @@ class MMBot(): # Use to send a failure to the user. Use only the first time during a request. Should retain input on clientside. - def respond_cmd_err(self, message, props=None): + def respond_cmd_err(self, message, props=None, http_code=400, if_nonzero_secondary='exc'): data = {"skip_slack_parsing":True, "response_type":"ephemeral", "text": "## :x: Failure! :(\n#### "+message} if props: data.update({"props": props}) # must be 2 separatecalls, as the message is ignored in a non-200. - self.respond(400) + self.respond(http_code=http_code, if_nonzero_secondary=if_nonzero_secondary) self.respond(000, data) -- 2.43.0