Add `ServiceShutdownFailed` to `AdminSharedError`
Adds the `ServiceShutdownFailed` error variant to the
`AdminSharedError` which takes the `ShutdownServiceError`'s
`ShutdownFailed` error variant in the orchestrator, for errors
to be correctly propagated when shutting down a service.
@@ -17,7 +17,7 @@ use std::fmt;
use crate::admin::store::error::AdminServiceStoreError;
use crate::consensus::error::ProposalManagerError;
-use crate::orchestrator::InitializeServiceError;
+use crate::orchestrator::{InitializeServiceError, ShutdownServiceError};
use crate::service::error::{ServiceError, ServiceSendError};
use protobuf::error;
@@ -161,6 +161,10 @@ pub enum AdminSharedError {
context: String,
source: Option<InitializeServiceError>,
},
+ ServiceShutdownFailed {
+ context: String,
+ source: Option<ShutdownServiceError>,
+ },
ServiceSendError(ServiceSendError),
UnknownAction(String),
ValidationFailed(String),
@@ -186,6 +190,13 @@ impl Error for AdminSharedError {
None
}
}
+ AdminSharedError::ServiceShutdownFailed { source, .. } => {
+ if let Some(ref err) = source {
+ Some(err)
+ } else {
+ None
+ }
+ }
AdminSharedError::ServiceSendError(err) => Some(err),
AdminSharedError::UnknownAction(_) => None,
AdminSharedError::ValidationFailed(_) => None,
@@ -213,6 +224,13 @@ impl fmt::Display for AdminSharedError {
f.write_str(&context)
}
}
+ AdminSharedError::ServiceShutdownFailed { context, source } => {
+ if let Some(ref err) = source {
+ write!(f, "{}: {}", context, err)
+ } else {
+ f.write_str(&context)
+ }
+ }
AdminSharedError::ServiceSendError(err) => {
write!(f, "failed to send service message: {}", err)
}
