Skip to content

Commit cae9423

Browse files
committed
Return error instead of panicing.
1 parent 2a7b528 commit cae9423

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/consumer/stream_consumer.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,20 @@ where
207207
fn from_config_and_context(config: &ClientConfig, context: C) -> KafkaResult<Self> {
208208
let native_config = config.create_native_config()?;
209209
let poll_interval = {
210-
let millis: u64 = native_config
211-
.get("max.poll.interval.ms")?
212-
.parse()
213-
.expect("librdkafka validated config value is valid u64");
214-
Duration::from_millis(millis)
210+
let millis = native_config.get("max.poll.interval.ms")?;
211+
match millis.parse() {
212+
Ok(millis) => Duration::from_millis(millis),
213+
Err(e) => {
214+
println!("Config string: '{}'", millis);
215+
println!("Error: '{}'", e);
216+
return Err(KafkaError::ClientConfig(
217+
RDKafkaConfRes::RD_KAFKA_CONF_INVALID,
218+
"max.poll.interval.ms".to_string(),
219+
format!("Invalid integer: {}", e),
220+
millis,
221+
));
222+
}
223+
}
215224
};
216225

217226
let base = Arc::new(BaseConsumer::new(config, native_config, context)?);

0 commit comments

Comments
 (0)