use engenho_apiserver::ServerError;
use engenho_config::ConfigError;
use engenho_store::StoreError;
#[derive(Debug, thiserror::Error)]
pub enum RuntimeError {
#[error("config error: {0}")]
Config(#[from] ConfigError),
#[error("store error: {0}")]
Store(#[from] StoreError),
#[error("apiserver error: {0}")]
Server(#[from] ServerError),
#[error("store did not reach leadership within {seconds}s")]
LeadershipTimeout {
seconds: u32,
},
#[error("invalid listen_addr {addr:?}: {source}")]
ListenAddr {
addr: String,
#[source]
source: std::net::AddrParseError,
},
#[error(
"could not acquire sole store ownership for terminate ({strong_count} strong refs remain)"
)]
StoreStillShared {
strong_count: usize,
},
#[error("kubeconfig emission failed: {0}")]
Kubeconfig(String),
#[error("kubeconfig io error at {path}: {source}")]
KubeconfigIo {
path: std::path::PathBuf,
#[source]
source: std::io::Error,
},
}
engenho_substrate::impl_error_kind! {
RuntimeError {
(Config(_)) => "config",
(Store(_)) => "store",
(Server(_)) => "server",
{ LeadershipTimeout { .. } } => "leadership_timeout",
{ ListenAddr { .. } } => "listen_addr",
{ StoreStillShared { .. } } => "store_still_shared",
(Kubeconfig(_)) => "kubeconfig",
{ KubeconfigIo { .. } } => "kubeconfig_io",
}
}