webhooks: Log json encoding errors

Signed-off-by: Justin Schuh <code@justinschuh.com>
This commit is contained in:
Justin Schuh 2023-04-08 19:34:32 -07:00 committed by KevinOConnor
parent 40b4b34998
commit d68a6c28ba
1 changed files with 8 additions and 2 deletions

View File

@ -268,8 +268,14 @@ class ClientConnection:
self.send(result)
def send(self, data):
try:
jmsg = json.dumps(data, separators=(',', ':'))
self.send_buffer += jmsg.encode() + b"\x03"
except (TypeError, ValueError) as e:
msg = ("json encoding error: %s" % (str(e),))
logging.exception(msg)
self.printer.invoke_shutdown(msg)
return
if not self.is_blocking:
self._do_send()