aboutsummaryrefslogtreecommitdiff
path: root/src/errors/injectable.rs
blob: df71f48a5bd58a706e5491fc7cc4f2a7b5e61ab0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Error types for structs that implement [`Injectable`].
//!
//! [`Injectable`]: crate::interfaces::injectable::Injectable

use crate::errors::di_container::DIContainerError;

/// Error type for structs that implement [`Injectable`].
///
/// [`Injectable`]: crate::interfaces::injectable::Injectable
#[derive(thiserror::Error, Debug)]
pub enum InjectableError
{
    /// Failed to resolve dependencies.
    #[error("Failed to resolve a dependency of '{affected}'")]
    ResolveFailed
    {
        /// The reason for the problem.
        #[source]
        reason: Box<DIContainerError>,

        /// The affected injectable type.
        affected: &'static str,
    },

    /// Failed to resolve dependencies.
    #[cfg(feature = "async")]
    #[error("Failed to resolve a dependency of '{affected}'")]
    AsyncResolveFailed
    {
        /// The reason for the problem.
        #[source]
        reason: Box<crate::errors::async_di_container::AsyncDIContainerError>,

        /// The affected injectable type.
        affected: &'static str,
    },
    /// Detected circular dependencies.
    #[error("Detected circular dependencies. {dependency_trace}")]
    DetectedCircular
    {
        /// A visual trace of dependencies.
        dependency_trace: String,
    },
}