From 39226fc1273770f5a26b92454f27cd5e3cefc54e Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 5 Feb 2023 19:54:16 +0100 Subject: [PATCH] style: use helper instead of buiding UserError by hand --- src/commands/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 6bc4db2c2..4d767d3a2 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -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(()) }