diff --git a/pkg/converter/converter.go b/pkg/converter/converter.go index 9a4d0e4..d5e2cdc 100644 --- a/pkg/converter/converter.go +++ b/pkg/converter/converter.go @@ -150,16 +150,10 @@ func (c *Converter) ParseMessage( msgParsed, err := parser(message.Value, c.Chain, txResult.Height) if err != nil { - if c.Chain.LogUnparsedMessages { - c.Logger.Error().Err(err).Str("type", message.TypeUrl).Msg("Error parsing message") - return &messages.MsgUnparsedMessage{Error: fmt.Errorf("Error parsing message: %s", err)} + return &messages.MsgUnparsedMessage{ + MsgType: message.TypeUrl, + Error: fmt.Errorf("Error parsing message: %s", err), } - - c.Logger.Debug(). - Err(err). - Str("type", message.TypeUrl). - Msg("Not logging unparsed messages, skipping.") - return nil } else if msgParsed == nil { c.Logger.Error().Str("type", message.TypeUrl).Msg("Got empty message after parsing") return nil diff --git a/pkg/filterer/filterer.go b/pkg/filterer/filterer.go index d0c8fb6..cf8bd66 100644 --- a/pkg/filterer/filterer.go +++ b/pkg/filterer/filterer.go @@ -124,6 +124,19 @@ func (f *Filterer) FilterMessage(message types.Message, internal bool) types.Mes } } + if unparsedMsg, ok := message.(*messagesPkg.MsgUnparsedMessage); ok { + if f.Chain.LogUnparsedMessages { + f.Logger.Error().Err(unparsedMsg.Error).Str("type", unparsedMsg.MsgType).Msg("Error parsing message") + return message + } + + f.Logger.Debug(). + Err(unparsedMsg.Error). + Str("type", unparsedMsg.MsgType). + Msg("Not logging unparsed messages, skipping.") + return nil + } + // internal -> filter only if f.Chain.FilterInternalMessages is true // !internal -> filter regardless if !internal || f.Chain.FilterInternalMessages { diff --git a/pkg/messages/msg_unparsed_message.go b/pkg/messages/msg_unparsed_message.go index 4211807..4df79cc 100644 --- a/pkg/messages/msg_unparsed_message.go +++ b/pkg/messages/msg_unparsed_message.go @@ -8,7 +8,8 @@ import ( ) type MsgUnparsedMessage struct { - Error error + MsgType string + Error error } func (m MsgUnparsedMessage) Type() string {