db-snapshot: Add error handling to metadata snapshot creation #930
1 changed files with 9 additions and 2 deletions
|
@ -482,7 +482,7 @@ impl AdminRpcHandler {
|
|||
AdminRpc::MetaOperation(MetaOperation::Snapshot { all: false }),
|
||||
PRIO_NORMAL,
|
||||
)
|
||||
.await
|
||||
.await?
|
||||
}))
|
||||
.await;
|
||||
|
||||
|
@ -495,7 +495,14 @@ impl AdminRpcHandler {
|
|||
ret.push(format!("{:?}\t{}", to, res_str));
|
||||
}
|
||||
|
||||
Ok(AdminRpc::Ok(format_table_to_string(ret)))
|
||||
if resps.iter().any(|resp| match resp {
|
||||
|
||||
Err(_) => true,
|
||||
Ok(_) => false,
|
||||
}) {
|
||||
Err(Error::BadRequest(format_table_to_string(ret)).into())
|
||||
lx
commented
`Error::Message` is more appropriate here
|
||||
} else {
|
||||
Ok(AdminRpc::Ok(format_table_to_string(ret)))
|
||||
}
|
||||
}
|
||||
MetaOperation::Snapshot { all: false } => {
|
||||
garage_model::snapshot::async_snapshot_metadata(&self.garage).await?;
|
||||
|
|
Loading…
Add table
Reference in a new issue
simplify:
resps.iter().any(Result::is_err)
I tried many different ways to simplify this code but I did not find anything satisfying. Thanks for the very nice solution :)