From 45641b8c39da7adb96fd4f04f83f00c1420e4755 Mon Sep 17 00:00:00 2001 From: 10maurycy10 <10maurycy10@gmail.com> Date: Mon, 24 Jan 2022 10:49:18 -0800 Subject: [PATCH] Fix rare crash --- shreddit/shredder.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shreddit/shredder.py b/shreddit/shredder.py index c4633a0..ef0876c 100644 --- a/shreddit/shredder.py +++ b/shreddit/shredder.py @@ -107,8 +107,11 @@ class Shredder(object): output = {k: item.__dict__[k] for k in item.__dict__ if not k.startswith("_")} output["subreddit"] = output["subreddit"].title output["author"] = output["author"].name - json.dump(output, fh, indent=2) - + try: + json.dump(output, fh, indent=2) + except: + print("could not save post!") + def _remove_submission(self, sub): self._logger.info("Deleting submission: #{id} {url}".format(id=sub.id, url=sub.url.encode("utf-8")))