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/main.rs | |
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/main.rs')
-rw-r--r-- | src/garage/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/garage/main.rs b/src/garage/main.rs index 69cd16e7..60a13ac7 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -22,6 +22,8 @@ use garage_util::error::*; use garage_rpc::system::*; use garage_rpc::*; +use garage_model::helper::error::Error as HelperError; + use admin::*; use cli::*; @@ -136,5 +138,9 @@ async fn cli_command(opt: Opt) -> Result<(), Error> { let system_rpc_endpoint = netapp.endpoint::<SystemRpc, ()>(SYSTEM_RPC_PATH.into()); let admin_rpc_endpoint = netapp.endpoint::<AdminRpc, ()>(ADMIN_RPC_PATH.into()); - cli_command_dispatch(opt.cmd, &system_rpc_endpoint, &admin_rpc_endpoint, id).await + match cli_command_dispatch(opt.cmd, &system_rpc_endpoint, &admin_rpc_endpoint, id).await { + Err(HelperError::Internal(i)) => Err(i), + Err(HelperError::BadRequest(b)) => Err(Error::Message(format!("bad request: {}", b))), + Ok(x) => Ok(x), + } } |