diff options
author | Alex Auvolat <alex@adnab.me> | 2022-01-03 13:58:05 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-01-04 12:52:46 +0100 |
commit | beeef4758e5ec0d521179a799a3237c2c0368911 (patch) | |
tree | eb2734647b3c6e62cef64a5f2b533ac694252c29 /src/garage/cli | |
parent | d8ab5bdc3e20759e5ba8a6844393757da3539372 (diff) | |
download | garage-beeef4758e5ec0d521179a799a3237c2c0368911.tar.gz garage-beeef4758e5ec0d521179a799a3237c2c0368911.zip |
Some movement of helper code and refactoring of error handling
Diffstat (limited to 'src/garage/cli')
-rw-r--r-- | src/garage/cli/cmd.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/garage/cli/cmd.rs b/src/garage/cli/cmd.rs index 834261e4..cca7c401 100644 --- a/src/garage/cli/cmd.rs +++ b/src/garage/cli/cmd.rs @@ -6,6 +6,8 @@ use garage_rpc::layout::*; use garage_rpc::system::*; use garage_rpc::*; +use garage_model::helper::error::Error as HelperError; + use crate::admin::*; use crate::cli::*; @@ -14,14 +16,14 @@ pub async fn cli_command_dispatch( system_rpc_endpoint: &Endpoint<SystemRpc, ()>, admin_rpc_endpoint: &Endpoint<AdminRpc, ()>, rpc_host: NodeID, -) -> Result<(), Error> { +) -> Result<(), HelperError> { match cmd { - Command::Status => cmd_status(system_rpc_endpoint, rpc_host).await, + Command::Status => Ok(cmd_status(system_rpc_endpoint, rpc_host).await?), Command::Node(NodeOperation::Connect(connect_opt)) => { - cmd_connect(system_rpc_endpoint, rpc_host, connect_opt).await + Ok(cmd_connect(system_rpc_endpoint, rpc_host, connect_opt).await?) } Command::Layout(layout_opt) => { - cli_layout_command_dispatch(layout_opt, system_rpc_endpoint, rpc_host).await + Ok(cli_layout_command_dispatch(layout_opt, system_rpc_endpoint, rpc_host).await?) } Command::Bucket(bo) => { cmd_admin(admin_rpc_endpoint, rpc_host, AdminRpc::BucketOperation(bo)).await @@ -149,7 +151,7 @@ pub async fn cmd_connect( println!("Success."); Ok(()) } - r => Err(Error::BadRpc(format!("Unexpected response: {:?}", r))), + m => Err(Error::unexpected_rpc_message(m)), } } @@ -157,7 +159,7 @@ pub async fn cmd_admin( rpc_cli: &Endpoint<AdminRpc, ()>, rpc_host: NodeID, args: AdminRpc, -) -> Result<(), Error> { +) -> Result<(), HelperError> { match rpc_cli.call(&rpc_host, &args, PRIO_NORMAL).await?? { AdminRpc::Ok(msg) => { println!("{}", msg); |