Some movement of helper code and refactoring of error handling

This commit is contained in:
Alex Auvolat
2022-01-03 13:58:05 +01:00
parent d8ab5bdc3e
commit beeef4758e
17 changed files with 137 additions and 66 deletions
+7 -1
View File
@@ -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),
}
}