diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/api/error.rs | 8 | ||||
-rw-r--r-- | src/rpc/rpc_helper.rs | 2 | ||||
-rw-r--r-- | src/util/error.rs | 13 | ||||
-rw-r--r-- | src/web/error.rs | 4 |
4 files changed, 15 insertions, 12 deletions
diff --git a/src/api/error.rs b/src/api/error.rs index 31ba7230..a57f926b 100644 --- a/src/api/error.rs +++ b/src/api/error.rs @@ -83,7 +83,9 @@ impl Error { Error::NotFound => StatusCode::NOT_FOUND, Error::Forbidden(_) => StatusCode::FORBIDDEN, Error::InternalError( - GarageError::Timeout | GarageError::RemoteError(_) | GarageError::Quorum(_, _, _), + GarageError::Timeout + | GarageError::RemoteError(_) + | GarageError::Quorum(_, _, _, _), ) => StatusCode::SERVICE_UNAVAILABLE, Error::InternalError(_) | Error::Hyper(_) | Error::Http(_) => { StatusCode::INTERNAL_SERVER_ERROR @@ -98,7 +100,9 @@ impl Error { Error::Forbidden(_) => "AccessDenied", Error::AuthorizationHeaderMalformed(_) => "AuthorizationHeaderMalformed", Error::InternalError( - GarageError::Timeout | GarageError::RemoteError(_) | GarageError::Quorum(_, _, _), + GarageError::Timeout + | GarageError::RemoteError(_) + | GarageError::Quorum(_, _, _, _), ) => "ServiceUnavailable", Error::InternalError(_) | Error::Hyper(_) | Error::Http(_) => "InternalError", _ => "InvalidRequest", diff --git a/src/rpc/rpc_helper.rs b/src/rpc/rpc_helper.rs index 7413508e..8c7cc681 100644 --- a/src/rpc/rpc_helper.rs +++ b/src/rpc/rpc_helper.rs @@ -203,7 +203,7 @@ impl RpcHelper { Ok(results) } else { let errors = errors.iter().map(|e| format!("{}", e)).collect::<Vec<_>>(); - Err(Error::Quorum(results.len(), to.len(), errors)) + Err(Error::Quorum(quorum, results.len(), to.len(), errors)) } } } diff --git a/src/util/error.rs b/src/util/error.rs index c8d3c680..626958da 100644 --- a/src/util/error.rs +++ b/src/util/error.rs @@ -48,12 +48,13 @@ pub enum Error { Timeout, #[error( - display = "Could not reach quorum. {} of {} request succeeded, others returned errors: {:?}", + display = "Could not reach quorum of {}. {} of {} request succeeded, others returned errors: {:?}", _0, _1, - _2 + _2, + _3 )] - Quorum(usize, usize, Vec<String>), + Quorum(usize, usize, usize, Vec<String>), #[error(display = "Bad RPC: {}", _0)] BadRpc(String), @@ -110,11 +111,7 @@ where fn err_context<C: std::borrow::Borrow<str>>(self, ctx: C) -> Result<T, Error> { match self { Ok(x) => Ok(x), - Err(e) => Err(Error::Message(format!( - "{}\nOriginal error: {}", - ctx.borrow(), - e - ))), + Err(e) => Err(Error::Message(format!("{}\n{}", ctx.borrow(), e))), } } } diff --git a/src/web/error.rs b/src/web/error.rs index 2ed7139f..426155c1 100644 --- a/src/web/error.rs +++ b/src/web/error.rs @@ -39,7 +39,9 @@ impl Error { Error::NotFound => StatusCode::NOT_FOUND, Error::ApiError(e) => e.http_status_code(), Error::InternalError( - GarageError::Timeout | GarageError::RemoteError(_) | GarageError::Quorum(_, _, _), + GarageError::Timeout + | GarageError::RemoteError(_) + | GarageError::Quorum(_, _, _, _), ) => StatusCode::SERVICE_UNAVAILABLE, Error::InternalError(_) => StatusCode::INTERNAL_SERVER_ERROR, _ => StatusCode::BAD_REQUEST, |