soph_core/error/
container.rs

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
45
46
#[derive(thiserror::Error, Debug)]
pub enum ContainerError {
    #[cfg(feature = "anyhow")]
    #[error(transparent)]
    Anyhow(#[from] anyhow::Error),

    #[error(transparent)]
    Box(#[from] crate::BoxError),

    #[error("[instance] `{instance}` boot failed: {source}")]
    Boot {
        instance: String,
        #[source]
        source: Box<Self>,
    },

    #[error("[instance] `{instance}` clean failed: {source}")]
    Clean {
        instance: String,
        #[source]
        source: Box<Self>,
    },

    #[cfg(feature = "eyre")]
    #[error(transparent)]
    Eyre(#[from] eyre::Report),

    #[error("{0}")]
    Message(String),

    #[error("[instance] `{instance}` register failed: {source}")]
    Register {
        instance: String,
        #[source]
        source: Box<Self>,
    },

    #[error("[instance] `{instance}` not registered")]
    Resolve { instance: String },
}

impl ContainerError {
    pub fn message(msg: impl Into<String>) -> Self {
        Self::Message(msg.into())
    }
}