diff options
author | HampusM <hampus@hampusmat.com> | 2022-08-25 20:21:49 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-08-27 14:28:23 +0200 |
commit | 1c46b68581213ca8ae6200daa32f626b5389b4b0 (patch) | |
tree | 8da649471db7893a2347a2df383324b84ac226f0 /src/errors | |
parent | 8e862c7998d0b59c71d20cbcbbc57031f734b6fa (diff) |
refactor!: make DI container have single get function
BREAKING CHANGE: The DI container get_singleton & get_factory functions have been replaced by the get function now returning a enum
Diffstat (limited to 'src/errors')
-rw-r--r-- | src/errors/di_container.rs | 20 | ||||
-rw-r--r-- | src/errors/mod.rs | 1 | ||||
-rw-r--r-- | src/errors/ptr.rs | 19 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/errors/di_container.rs b/src/errors/di_container.rs index 98c2be4..4a74b5d 100644 --- a/src/errors/di_container.rs +++ b/src/errors/di_container.rs @@ -14,20 +14,6 @@ pub enum DIContainerError #[error("Unable to cast binding for interface '{0}'")] CastFailed(&'static str), - /// Wrong binding type. - #[error("Wrong binding type for interface '{interface}'. Expected a {expected}. Found a {found}")] - WrongBindingType - { - /// The affected bound interface. - interface: &'static str, - - /// The expected binding type. - expected: &'static str, - - /// The found binding type. - found: String, - }, - /// Failed to resolve a binding for a interface. #[error("Failed to resolve binding for interface '{interface}'")] BindingResolveFailed @@ -43,6 +29,10 @@ pub enum DIContainerError /// No binding exists for a interface. #[error("No binding exists for interface '{0}'")] BindingNotFound(&'static str), + + /// The binding for a interface is a factory but the factory feature isn't enabled. + #[error("The binding for interface '{0}' is a factory but the factory feature isn't enabled")] + CantHandleFactoryBinding(&'static str), } /// Error type for [`BindingBuilder`]. @@ -58,7 +48,7 @@ pub enum BindingBuilderError /// Error type for [`BindingScopeConfigurator`]. /// -/// [`BindingBuilder`]: crate::di_container::BindingScopeConfigurator +/// [`BindingScopeConfigurator`]: crate::di_container::BindingScopeConfigurator #[derive(thiserror::Error, Debug)] pub enum BindingScopeConfiguratorError { diff --git a/src/errors/mod.rs b/src/errors/mod.rs index 5f628d6..7d66ddf 100644 --- a/src/errors/mod.rs +++ b/src/errors/mod.rs @@ -2,3 +2,4 @@ pub mod di_container; pub mod injectable; +pub mod ptr; diff --git a/src/errors/ptr.rs b/src/errors/ptr.rs new file mode 100644 index 0000000..e0c3d05 --- /dev/null +++ b/src/errors/ptr.rs @@ -0,0 +1,19 @@ +//! Smart pointer alias errors. + +/// Error type for [`SomePtr`]. +/// +/// [`SomePtr`]: crate::ptr::SomePtr +#[derive(thiserror::Error, Debug)] +pub enum SomePtrError +{ + /// Tried to get as a wrong smart pointer type. + #[error("Wrong smart pointer type. Expected {expected}, found {found}")] + WrongPtrType + { + /// The expected smart pointer type. + expected: &'static str, + + /// The found smart pointer type. + found: &'static str, + }, +} |