Skip to main content

butterfly_bot/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum ButterflyBotError {
5    #[error("configuration error: {0}")]
6    Config(String),
7    #[error("http error: {0}")]
8    Http(String),
9    #[error("serialization error: {0}")]
10    Serialization(String),
11    #[error("runtime error: {0}")]
12    Runtime(String),
13    #[error("security policy error: {0}")]
14    SecurityPolicy(String),
15    #[error("security storage error: {0}")]
16    SecurityStorage(String),
17}
18
19pub use crate::Result;
20pub fn result_ok() -> Result<()> {
21    Ok(())
22}
23
24#[cfg(test)]
25pub fn coverage_probe() -> Result<()> {
26    Ok(())
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn covers_error_probe_and_display() {
35        coverage_probe().unwrap();
36        result_ok().unwrap();
37        let err = ButterflyBotError::Config("x".to_string());
38        assert!(format!("{err}").contains("configuration error"));
39    }
40}