forked from mirrors/jj
style: use helper instead of buiding UserError by hand
This commit is contained in:
parent
a7e2c06068
commit
39226fc127
1 changed files with 4 additions and 8 deletions
|
@ -3146,14 +3146,10 @@ fn cmd_workspace_root(
|
||||||
_args: &WorkspaceRootArgs,
|
_args: &WorkspaceRootArgs,
|
||||||
) -> Result<(), CommandError> {
|
) -> Result<(), CommandError> {
|
||||||
let workspace_command = command.workspace_helper(ui)?;
|
let workspace_command = command.workspace_helper(ui)?;
|
||||||
let root =
|
let root = workspace_command
|
||||||
workspace_command
|
.workspace_root()
|
||||||
.workspace_root()
|
.to_str()
|
||||||
.to_str()
|
.ok_or_else(|| user_error("The workspace root is not valid UTF-8"))?;
|
||||||
.ok_or_else(|| CommandError::UserError {
|
|
||||||
message: String::from("The workspace root is not valid UTF-8"),
|
|
||||||
hint: None,
|
|
||||||
})?;
|
|
||||||
writeln!(ui, "{root}")?;
|
writeln!(ui, "{root}")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue