use crate::errors::injectable::InjectableError;
#[derive(thiserror::Error, Debug)]
pub enum DIContainerError
{
#[error(
"Unable to cast binding for interface '{interface} with kind '{binding_kind}'"
)]
CastFailed
{
interface: &'static str,
binding_kind: &'static str,
},
#[error("Failed to resolve binding for interface '{interface}'")]
BindingResolveFailed
{
#[source]
reason: InjectableError,
interface: &'static str,
},
#[error(
"No binding exists for interface '{interface}' {}",
name.as_ref().map(|name| format!("with name '{name}'")).unwrap_or_default()
)]
BindingNotFound
{
interface: &'static str,
name: Option<String>,
},
}
#[derive(thiserror::Error, Debug)]
pub enum BindingBuilderError
{
#[error("Binding already exists for interface '{0}'")]
BindingAlreadyExists(&'static str),
}
#[derive(thiserror::Error, Debug)]
pub enum BindingScopeConfiguratorError
{
#[error("Resolving the given singleton failed")]
SingletonResolveFailed(#[from] InjectableError),
}
#[derive(thiserror::Error, Debug)]
pub enum BindingWhenConfiguratorError
{
#[error("A binding for interface '{0}' wasn't found'")]
BindingNotFound(&'static str),
}