feat(client): Reject empty open_timeouts configuration with dedicated error
This commit is contained in:
1 parent
04ebaf829a
commit
befe431304
3 files changed
+17
No files matched your search
@@ -791,4 +791,16 @@ mod tests {
|
||||
Err(ClientError::OpenTimeoutTooSmall { .. })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_open_timeouts_is_rejected() {
|
||||
let config = ClientConfig {
|
||||
open_timeouts: vec![],
|
||||
..ClientConfig::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
Client::connect(config),
|
||||
Err(ClientError::NoOpenTimeouts)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ pub enum ClientError {
|
||||
timeout: Duration,
|
||||
minimum: Duration,
|
||||
},
|
||||
#[error("open_timeouts must not be empty")]
|
||||
NoOpenTimeouts,
|
||||
#[error("server rejected the open request")]
|
||||
ServerRejected,
|
||||
#[error("unexpected no-test open reply")]
|
||||
|
||||
@@ -11,6 +11,9 @@ use crate::{
|
||||
};
|
||||
|
||||
pub(crate) fn validate_open_timeouts(timeouts: &[Duration]) -> Result<(), ClientError> {
|
||||
if timeouts.is_empty() {
|
||||
return Err(ClientError::NoOpenTimeouts);
|
||||
}
|
||||
for timeout in timeouts {
|
||||
if *timeout < MIN_OPEN_TIMEOUT {
|
||||
return Err(ClientError::OpenTimeoutTooSmall {
|
||||
|
||||
Reference in new issue
Block a user