Skip to content

Commit 7b7d77b

Browse files
committed
Improve error message, add another error message
1 parent 00197b2 commit 7b7d77b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cachedev.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,19 @@ impl FromStr for CacheTargetParams {
118118
let policy = vals[end_feature_args_index].to_owned();
119119

120120
if vals.len() <= end_feature_args_index + 1 {
121-
let err_msg = format!("Expected more arguments than were provided",);
121+
let err_msg = format!("Only {} arguments provided, expected more", vals.len());
122122
return Err(DmError::Dm(ErrorEnum::Invalid, err_msg));
123123
}
124124

125125
let num_policy_args: usize =
126126
parse_value(vals[end_feature_args_index + 1], "number of policy args")?;
127+
128+
let num_expected_args = 8 + num_feature_args + num_policy_args;
129+
if vals.len() < num_expected_args {
130+
let err_msg = format!("Based on number of feature arguments and policy args provided, {} arguments were expected, but {} were provided", num_expected_args, vals.len());
131+
return Err(DmError::Dm(ErrorEnum::Invalid, err_msg));
132+
}
133+
127134
let start_policy_args_index = end_feature_args_index + 2;
128135
let end_policy_args_index = start_policy_args_index + num_policy_args;
129136
let policy_args: Vec<(String, String)> = vals

0 commit comments

Comments
 (0)