webhooks: Log json encoding errors

Signed-off-by: Justin Schuh <code@justinschuh.com>
This commit is contained in:
Justin Schuh authored and KevinOConnor committed 2023-04-19 12:22:20 -04:00
1 parent 40b4b34998
commit d68a6c28ba
1 file changed
+8 -2
+8 -2
View File
@@ -268,8 +268,14 @@ class ClientConnection:
self.send(result)
def send(self, data):
jmsg = json.dumps(data, separators=(',', ':'))
self.send_buffer += jmsg.encode() + b"\x03"
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()