fd4s / fs2-kafka

Functional Kafka Streams for Scala
https://fd4s.github.io/fs2-kafka
Apache License 2.0
293 stars 101 forks source link

Misleading error message in `NotSubscribedException` #981

Closed danielleontiev closed 8 months ago

danielleontiev commented 2 years ago

The message says "consumer is not subscribed to any topics". Also, in javadoc comments in KafkaConsume.scala it's mentioned multiple times that

* @note you have to first use `subscribe` to subscribe the consumer
    *       before using this `Stream`. If you forgot to subscribe, there
    *       will be a [[NotSubscribedException]] raised in the `Stream`.

But it's not completely correct. To avoid the exception you could either subscribe to the topic or assign partitions manually. For example, underlying org.apache.kafka.clients.consumer.KafkaConsumer uses the following error message inside its poll method:

throw new IllegalStateException("Consumer is not subscribed to any topics or assigned any partitions")
aartigao commented 8 months ago

Fair. The ScalaDoc seems to be updated, but the exception message not. I'm fixing this.