From 1a52ed2c9a219e270897efd21a7b3b0bef7e034a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 20 Jul 2018 20:47:10 +0200 Subject: [PATCH] Add error handling logic to MessageStorage --- lib/tfw/networking/server/tfw_server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tfw/networking/server/tfw_server.py b/lib/tfw/networking/server/tfw_server.py index f0471ef..5f297df 100644 --- a/lib/tfw/networking/server/tfw_server.py +++ b/lib/tfw/networking/server/tfw_server.py @@ -2,6 +2,7 @@ # All Rights Reserved. See LICENSE file for details. from abc import ABC, abstractmethod +from contextlib import suppress from tornado.web import Application @@ -61,8 +62,9 @@ class MessageStorage(ABC): self.saved_messages = [] def save_message(self, message): - if self.filter_message(message): - self.saved_messages.extend(self.transform_message(message)) + with suppress(KeyError, AttributeError): + if self.filter_message(message): + self.saved_messages.extend(self.transform_message(message)) @abstractmethod def filter_message(self, message):