cli/show: improve error messages

This commit is contained in:
Dmitriy Pleshevskiy 2022-08-18 17:29:24 +03:00
parent b0cca6a408
commit bd4a581f3e
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215

View file

@ -58,10 +58,10 @@ pub fn execute(repo: impl Repository, args: Args) {
Err(idx_err) => match first.parse::<PrintPart>() { Err(idx_err) => match first.parse::<PrintPart>() {
Ok(part) => (None, Some(part)), Ok(part) => (None, Some(part)),
Err(part_err) => { Err(part_err) => {
return eprint!( eprintln!("error: Invalid value {first:?}:");
r#"error: Invalid value "{}": {}; {}"#, eprintln!("- {idx_err}");
first, idx_err, part_err eprintln!("- {part_err}");
) return;
} }
}, },
} }
@ -73,16 +73,16 @@ pub fn execute(repo: impl Repository, args: Args) {
let idx = match first.parse::<usize>() { let idx = match first.parse::<usize>() {
Ok(idx) => Some(idx), Ok(idx) => Some(idx),
Err(err) => return eprint!(r#"error: Invalid value "{}": {}"#, first, err), Err(err) => return eprintln!("error: Invalid value {first:?}: {err}"),
}; };
let part = match second.parse::<PrintPart>() { let part = match second.parse::<PrintPart>() {
Ok(part) => Some(part), Ok(part) => Some(part),
Err(err) => return eprint!(r#"error: Invalid value "{}": {}"#, second, err), Err(err) => return eprintln!("error: Invalid value {second:?}: {err}"),
}; };
(idx, part) (idx, part)
} }
_ => return eprintln!("error: To much arguments: {}", args.rest.join(",")), _ => return eprintln!("error: To much arguments: {:?}", args.rest),
}; };
let task = if let Some(idx) = idx { let task = if let Some(idx) = idx {