code: func (ref *AsyncProducer) errorHandler(in <-chan *sarama.ProducerError) {
  	ref.Debug("starting error handler ...")
  	for {
  		select {
  		case <-ref.closeChannel:
  			ref.Debug("error handler exited ...")
  			return
  		case perr := <-in:
  			if perr == nil {
  				continue
  			}
  
  			msg := perr.Msg
  			err := perr.Err
  			pmsg := &ProducerMessage{
  				Topic:     msg.Topic,
  				Key:       msg.Key,
  				Value:     msg.Value,
  				Metadata:  msg.Metadata,
  				Offset:    msg.Offset,
  				Partition: msg.Partition,
  			}
  			perr2 := &ProducerError{
  				ProducerMessage: pmsg,
  				Err:             err,
  			}
  			val, _ := msg.Value.Encode()
  			ref.Errorf("message %s errored in topic(%s)/partition(%d)/offset(%d)\n", string(val), pmsg.Topic, pmsg.Partition, pmsg.Offset)
  			ref.Errorf("message error: %v", perr.Err)
  			ref.Config.ErrorChan <- perr2
  		}
  	}
  }
docs: // errorHandler handles error messages