Skip to main content

ContainerError

Struct ContainerError 

Source
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: ContainerErrorKind

The specific kind of error that occurred

§message: String

A 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

Source

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 occurred
  • message - A descriptive error message
§Examples
use verdure_core::error::container::{ContainerError, ContainerErrorKind};

let error = ContainerError::new(ContainerErrorKind::NotFound, "Component missing");
Source

pub fn with_source<E>(self, err: E) -> Self
where E: Error + Send + Sync + 'static,

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);
Source

pub fn not_found<M: Into<String>>(message: M) -> Self

Creates a new “not found” error

§Arguments
  • message - A descriptive message about what was not found
Source

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
Source

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
Source

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
Source

pub fn configuration<M: Into<String>>(message: M) -> Self

Creates a new “configuration” error

§Arguments
  • message - A descriptive message about the configuration error
Source

pub fn other<M: Into<String>>(message: M) -> Self

Creates a new “other” error

§Arguments
  • message - A descriptive message about the error

Trait Implementations§

Source§

impl Debug for ContainerError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ContainerError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ContainerError

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<&str> for ContainerError

Source§

fn from(msg: &str) -> Self

Converts to this type from the input type.
Source§

impl From<ComponentError> for ContainerError

Source§

fn from(err: ComponentError) -> Self

Converts to this type from the input type.
Source§

impl From<ContainerError> for ComponentError

Source§

fn from(err: ContainerError) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ContainerError

Source§

fn from(msg: String) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.