diff --git a/connection.go b/connection.go index 8c081ea..93b68ee 100644 --- a/connection.go +++ b/connection.go @@ -175,7 +175,7 @@ func (c *Connection) TypeMappingHandler(handler HandlerFunc) HandlerFunc { routingKey := headers["routing-key"].(string) typ, exists := c.keyToType[routingKey] if !exists { - return nil, fmt.Errorf("no mapped type found for routing key '%s'", routingKey) + return nil, nil } body := []byte(*msg.(*json.RawMessage)) message, err := c.parseMessage(body, typ) diff --git a/connection_test.go b/connection_test.go index 569f7bf..29b334b 100644 --- a/connection_test.go +++ b/connection_test.go @@ -563,7 +563,7 @@ func TestConnection_TypeMappingHandler(t *testing.T) { wantErr assert.ErrorAssertionFunc }{ { - name: "no mapped type", + name: "no mapped type, ignored", fields: fields{}, args: args{ msg: []byte(`{"a":true}`), @@ -574,10 +574,8 @@ func TestConnection_TypeMappingHandler(t *testing.T) { } }, }, - want: nil, - wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { - return assert.EqualError(t, err, "no mapped type found for routing key 'unknown'") - }, + want: nil, + wantErr: assert.NoError, }, { name: "parse error",