ferro_notifications/
error.rs1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("mail error: {0}")]
10 Mail(String),
11
12 #[error("slack error: {0}")]
14 Slack(String),
15
16 #[error("database error: {0}")]
18 Database(String),
19
20 #[error("channel not available: {0}")]
22 ChannelNotAvailable(String),
23
24 #[error("serialization error: {0}")]
26 Serialization(#[from] serde_json::Error),
27
28 #[error("{0}")]
30 Other(String),
31}
32
33impl Error {
34 pub fn mail(msg: impl Into<String>) -> Self {
36 Self::Mail(msg.into())
37 }
38
39 pub fn slack(msg: impl Into<String>) -> Self {
41 Self::Slack(msg.into())
42 }
43
44 pub fn database(msg: impl Into<String>) -> Self {
46 Self::Database(msg.into())
47 }
48}