Make SettingsError easier to diagnose;

This commit is contained in:
Benjamin Bouvier
2018-10-03 14:58:07 +02:00
committed by Dan Gohman
parent 8b296e4874
commit de1d82b4ba
2 changed files with 38 additions and 17 deletions

View File

@@ -43,14 +43,21 @@ where
match opt {
TestOption::Flag(name) => match config.enable(name) {
Ok(_) => {}
Err(SetError::BadName) => return err!(loc, "unknown flag '{}'", opt),
Err(SetError::BadName(name)) => return err!(loc, "unknown flag '{}'", name),
Err(_) => return err!(loc, "not a boolean flag: '{}'", opt),
},
TestOption::Value(name, value) => match config.set(name, value) {
Ok(_) => {}
Err(SetError::BadName) => return err!(loc, "unknown setting '{}'", opt),
Err(SetError::BadName(name)) => return err!(loc, "unknown setting '{}'", name),
Err(SetError::BadType) => return err!(loc, "invalid setting type: '{}'", opt),
Err(SetError::BadValue) => return err!(loc, "invalid setting value: '{}'", opt),
Err(SetError::BadValue(expected)) => {
return err!(
loc,
"invalid setting value for '{}', expected {}",
opt,
expected
)
}
},
}
}