pub enum DiError {
NotFound(&'static str),
TypeMismatch(&'static str),
Circular(Vec<&'static str>),
WrongLifetime(&'static str),
DepthExceeded(usize),
}Expand description
Dependency injection errors
Represents the various error conditions that can occur during service registration, resolution, or container operations in ferrous-di.
§Examples
use ferrous_di::{DiError, ServiceCollection, Resolver};
// Example of NotFound error
let provider = ServiceCollection::new().build();
match provider.get::<String>() {
Err(DiError::NotFound(type_name)) => {
assert_eq!(type_name, "alloc::string::String");
println!("Service not found: {}", type_name);
}
_ => unreachable!(),
}use ferrous_di::DiError;
// Examples of error types
let not_found = DiError::NotFound("MyService");
let type_mismatch = DiError::TypeMismatch("std::string::String");
let circular = DiError::Circular(vec!["ServiceA", "ServiceB", "ServiceA"]);
let wrong_lifetime = DiError::WrongLifetime("Cannot resolve scoped from singleton");
let depth_exceeded = DiError::DepthExceeded(100);
// All errors implement Display
println!("Error: {}", not_found);
println!("Error: {}", circular);Variants§
NotFound(&'static str)
Service not registered
TypeMismatch(&'static str)
Type downcast failed
Circular(Vec<&'static str>)
Circular dependency detected (includes path)
WrongLifetime(&'static str)
Invalid lifetime resolution (e.g., scoped from root)
DepthExceeded(usize)
Maximum recursion depth exceeded
Trait Implementations§
Source§impl Error for DiError
impl Error for DiError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for DiError
impl RefUnwindSafe for DiError
impl Send for DiError
impl Sync for DiError
impl Unpin for DiError
impl UnwindSafe for DiError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more