style: use helper instead of buiding UserError by hand

This commit is contained in:
Samuel Tardieu 2023-02-05 19:54:16 +01:00
parent a7e2c06068
commit 39226fc127

View file

@ -3146,14 +3146,10 @@ fn cmd_workspace_root(
_args: &WorkspaceRootArgs,
) -> Result<(), CommandError> {
let workspace_command = command.workspace_helper(ui)?;
let root =
workspace_command
.workspace_root()
.to_str()
.ok_or_else(|| CommandError::UserError {
message: String::from("The workspace root is not valid UTF-8"),
hint: None,
})?;
let root = workspace_command
.workspace_root()
.to_str()
.ok_or_else(|| user_error("The workspace root is not valid UTF-8"))?;
writeln!(ui, "{root}")?;
Ok(())
}