1use thiserror::Error;
2#[derive(Error, Debug, Clone)]
3pub enum RdiError {
4 #[error("service not registered: {ty}{}", context.as_ref().map(|c| format!(" (while resolving {c})")).unwrap_or_default())]
5 ServiceNotFound {
6 ty: &'static str,
7 context: Option<String>,
8 },
9 #[error("keyed service not registered: key={key}, type={ty}")]
10 KeyedServiceNotFound { key: String, ty: &'static str },
11 #[error("circular dependency detected: {0}")]
12 CircularDependency(String),
13 #[error("singleton '{singleton}' cannot depend on scoped service '{scoped}'")]
14 SingletonDependsOnScoped { singleton: String, scoped: String },
15 #[error("factory panicked while resolving service '{service}': {payload}")]
16 FactoryPanic { service: String, payload: String },
17 #[error("cannot resolve owned instance of '{0}': Singleton services cannot be owned")]
18 OwnedNotSupported(&'static str),
19}