Skip to content

Commit cf3bcc6

Browse files
committed
Detailed message of exceeding maximum parameters
1 parent d451745 commit cf3bcc6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/pulse.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,22 @@ where
117117
let sample_rate = u32::try_from(params.sample_rate)
118118
.ok()
119119
.filter(|&sample_rate| sample_rate <= PA_RATE_MAX)
120-
.ok_or_else(|| "sample rate exceeds maximum value".to_owned())?;
120+
.ok_or_else(|| {
121+
format!(
122+
"sample rate {} exceeds maximum allowed {}",
123+
params.sample_rate, PA_RATE_MAX,
124+
)
125+
})?;
121126

122127
let channels_count = u8::try_from(params.channels_count)
123128
.ok()
124129
.filter(|&channels_count| channels_count <= PA_CHANNELS_MAX)
125-
.ok_or_else(|| "channels count exceeds maximum value".to_owned())?;
130+
.ok_or_else(|| {
131+
format!(
132+
"channels count {} exceeds maximum allowed {}",
133+
params.channels_count, PA_CHANNELS_MAX,
134+
)
135+
})?;
126136

127137
let spec = pa_sample_spec {
128138
format: PA_SAMPLE_FLOAT32LE,

0 commit comments

Comments
 (0)