Add error handling logic to MessageStorage

This commit is contained in:
Kristóf Tóth 2018-07-20 20:47:10 +02:00
parent bad7297c94
commit 1a52ed2c9a

View File

@ -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):