From 54a4c7e55a3d8c4c4e5add71cc1a52032b66b9d1 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 23 Nov 2020 01:20:40 +0000 Subject: [PATCH] fix with try-catch --- apiserver/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apiserver/server.py b/apiserver/server.py index 585a10d..b831746 100644 --- a/apiserver/server.py +++ b/apiserver/server.py @@ -168,8 +168,11 @@ def _update_current_story(item): valid = feed.update_story(story, urlref=item['urlref']) if valid: - database.put_story(story) - search.put_story(story) + try: + database.put_story(story) + search.put_story(story) + except database.IntegrityError: + logging.info('Unable to add story with ref ' + ref) else: database.del_ref(item['ref']) logging.info('Removed ref {}'.format(item['ref']))