aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Schuh <jschuh@users.noreply.github.com>2023-04-08 19:34:32 -0700
committerKevinOConnor <kevin@koconnor.net>2023-04-19 12:22:20 -0400
commitd68a6c28ba93df4f9bca6cb5a4bde4da09adfa0e (patch)
treef75ea96bf927af8e89520414e5758587dfbc1667
parent40b4b34998c0708b2050c394feb383f901b76a0b (diff)
downloadkutter-d68a6c28ba93df4f9bca6cb5a4bde4da09adfa0e.tar.gz
kutter-d68a6c28ba93df4f9bca6cb5a4bde4da09adfa0e.tar.xz
kutter-d68a6c28ba93df4f9bca6cb5a4bde4da09adfa0e.zip
webhooks: Log json encoding errors
Signed-off-by: Justin Schuh <code@justinschuh.com>
-rw-r--r--klippy/webhooks.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/klippy/webhooks.py b/klippy/webhooks.py
index 43ff9a91..9188a4f7 100644
--- a/klippy/webhooks.py
+++ b/klippy/webhooks.py
@@ -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()