diff options
Diffstat (limited to 'src/errors/di_container.rs')
-rw-r--r-- | src/errors/di_container.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/errors/di_container.rs b/src/errors/di_container.rs index 65cd9d1..82a3d55 100644 --- a/src/errors/di_container.rs +++ b/src/errors/di_container.rs @@ -26,9 +26,19 @@ pub enum DIContainerError interface: &'static str, }, - /// No binding exists for a interface. - #[error("No binding exists for interface '{0}'")] - BindingNotFound(&'static str), + /// No binding exists for a interface (and optionally a name). + #[error( + "No binding exists for interface '{interface}' {}", + .name.map_or_else(String::new, |name| format!("with name '{}'", name)) + )] + BindingNotFound + { + /// The interface that doesn't have a binding. + interface: &'static str, + + /// The name of the binding if one exists. + name: Option<&'static str>, + }, } /// Error type for [`BindingBuilder`]. @@ -52,3 +62,14 @@ pub enum BindingScopeConfiguratorError #[error("Resolving the given singleton failed")] SingletonResolveFailed(#[from] InjectableError), } + +/// Error type for [`BindingWhenConfigurator`]. +/// +/// [`BindingWhenConfigurator`]: crate::di_container::BindingWhenConfigurator +#[derive(thiserror::Error, Debug)] +pub enum BindingWhenConfiguratorError +{ + /// A binding for a interface wasn't found. + #[error("A binding for interface '{0}' wasn't found'")] + BindingNotFound(&'static str), +} |