diff --git a/fluent/handler.py b/fluent/handler.py index 7aefd8f..d7dea03 100644 --- a/fluent/handler.py +++ b/fluent/handler.py @@ -229,13 +229,17 @@ def getSenderInstance(self, tag, host, port, timeout, verbose, nanosecond_precision=nanosecond_precision, **kwargs) def emit(self, record): - data = self.format(record) - _sender = self.sender - return _sender.emit_with_time(None, - sender.EventTime(record.created) - if _sender.nanosecond_precision - else int(record.created), - data) + try: + data = self.format(record) + _sender = self.sender + return _sender.emit_with_time(None, + sender.EventTime(record.created) + if _sender.nanosecond_precision + else int(record.created), + data) + except Exception as e: + self.handleError(record) + raise e def close(self): self.acquire()