ayun_core/errors/
mod.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
pub use container::ContainerError;

mod container;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[cfg(feature = "anyhow")]
    #[error(transparent)]
    Anyhow(#[from] anyhow::Error),

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

    #[error(transparent)]
    Container(#[from] ContainerError),

    #[error(transparent)]
    EnvVar(#[from] std::env::VarError),

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

    #[error(transparent)]
    Io(#[from] std::io::Error),

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

    #[cfg(feature = "auth")]
    #[error(transparent)]
    JsonWebToken(#[from] jsonwebtoken::errors::Error),

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

    #[cfg(feature = "opendal")]
    #[error(transparent)]
    Opendal(#[from] opendal::Error),

    #[cfg(feature = "hash")]
    #[error(transparent)]
    PasswordHashError(#[from] argon2::password_hash::Error),

    #[cfg(feature = "redis")]
    #[error(transparent)]
    RedisError(#[from] bb8_redis::redis::RedisError),

    #[cfg(feature = "redis")]
    #[error("redis ping failed")]
    RedisPing,

    #[cfg(feature = "redis")]
    #[error(transparent)]
    RedisRunError(#[from] bb8_redis::bb8::RunError<bb8_redis::redis::RedisError>),

    #[cfg(feature = "database")]
    #[error(transparent)]
    SeaOrm(#[from] sea_orm::DbErr),

    #[cfg(feature = "storage")]
    #[error(transparent)]
    Storage(#[from] object_store::Error),

    #[cfg(feature = "logger")]
    #[error(transparent)]
    TracingFilterParseError(#[from] tracing_subscriber::filter::ParseError),

    #[cfg(feature = "auth")]
    #[error("{0}")]
    Unauthorized(String),
}

impl crate::traits::ErrorTrait for Error {}

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