create match on formatter output

This commit is contained in:
Andika Demas Riyandi 2021-04-08 13:33:26 +07:00
parent c3512d12b6
commit d3ade342bd
2 changed files with 5 additions and 2 deletions

View File

@ -221,7 +221,6 @@ pub fn run_treefmt(
}
Err(err) => {
// FIXME: What is the right behaviour if a formatter has failed running?
// error!("{} failed: {}", &formatter, err);
// Assume the paths were not formatted
return Err(anyhow!("{} failed: {}", &formatter, err));
}

View File

@ -98,7 +98,11 @@ impl Formatter {
// Append all of the file paths to format.
cmd_arg.args(paths);
// And run
Ok(cmd_arg.output()?)
match cmd_arg.output() {
Ok(out) => Ok(out),
Err(err) => Err(anyhow!("formatting error due to {}", err))
}
// Ok(cmd_arg.output()?)
}
/// Returns the formatter if the path matches the formatter rules.