Make SettingsError easier to diagnose;
This commit is contained in:
committed by
Dan Gohman
parent
8b296e4874
commit
de1d82b4ba
@@ -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
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user