pub struct ContainerError {
pub kind: ContainerErrorKind,
pub message: String,
pub source: Option<Box<dyn Error + Send + Sync>>,
}Expand description
The main error type for container operations
ContainerError represents various failure conditions that can occur during
container initialization, component creation, and dependency resolution.
§Examples
use verdure_core::error::container::{ContainerError, ContainerErrorKind};
let error = ContainerError::not_found("ComponentA not found");
println!("{}", error); // Prints: "Component not found: ComponentA not found"Fields§
§kind: ContainerErrorKindThe specific kind of error that occurred
message: StringA human-readable error message describing the issue
source: Option<Box<dyn Error + Send + Sync>>Optional source error that caused this error
Implementations§
Source§impl ContainerError
impl ContainerError
Sourcepub fn new<M: Into<String>>(kind: ContainerErrorKind, message: M) -> Self
pub fn new<M: Into<String>>(kind: ContainerErrorKind, message: M) -> Self
Creates a new ContainerError with the specified kind and message
§Arguments
kind- The kind of error that occurredmessage- A descriptive error message
§Examples
use verdure_core::error::container::{ContainerError, ContainerErrorKind};
let error = ContainerError::new(ContainerErrorKind::NotFound, "Component missing");Sourcepub fn with_source<E>(self, err: E) -> Self
pub fn with_source<E>(self, err: E) -> Self
Adds a source error to this ContainerError
This is useful for error chaining, where one error is caused by another.
§Arguments
err- The source error that caused this error
§Examples
use verdure_core::error::container::ContainerError;
use std::io::Error;
let io_error = Error::new(std::io::ErrorKind::NotFound, "file not found");
let container_error = ContainerError::creation_failed("Failed to load config")
.with_source(io_error);Sourcepub fn circular_dependency<M: Into<String>>(message: M) -> Self
pub fn circular_dependency<M: Into<String>>(message: M) -> Self
Creates a new “circular dependency” error
§Arguments
message- A descriptive message about the circular dependency
Sourcepub fn creation_failed<M: Into<String>>(message: M) -> Self
pub fn creation_failed<M: Into<String>>(message: M) -> Self
Creates a new “creation failed” error
§Arguments
message- A descriptive message about the creation failure
Sourcepub fn type_cast_failed<M: Into<String>>(message: M) -> Self
pub fn type_cast_failed<M: Into<String>>(message: M) -> Self
Creates a new “type cast failed” error
§Arguments
message- A descriptive message about the type cast failure
Sourcepub fn configuration<M: Into<String>>(message: M) -> Self
pub fn configuration<M: Into<String>>(message: M) -> Self
Creates a new “configuration” error
§Arguments
message- A descriptive message about the configuration error
Trait Implementations§
Source§impl Debug for ContainerError
impl Debug for ContainerError
Source§impl Display for ContainerError
impl Display for ContainerError
Source§impl Error for ContainerError
impl Error for ContainerError
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()
Source§impl From<&str> for ContainerError
impl From<&str> for ContainerError
Source§impl From<ComponentError> for ContainerError
impl From<ComponentError> for ContainerError
Source§fn from(err: ComponentError) -> Self
fn from(err: ComponentError) -> Self
Converts to this type from the input type.
Source§impl From<ContainerError> for ComponentError
impl From<ContainerError> for ComponentError
Source§fn from(err: ContainerError) -> Self
fn from(err: ContainerError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for ContainerError
impl !UnwindSafe for ContainerError
impl Freeze for ContainerError
impl Send for ContainerError
impl Sync for ContainerError
impl Unpin for ContainerError
impl UnsafeUnpin for ContainerError
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