outbox_pattern_processor/
error.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
use std::fmt;

#[derive(Debug)]
pub struct OutboxPatternProcessorError {
    pub status_code: u16,
    pub cause: String,
    pub message: Option<String>,
}

impl OutboxPatternProcessorError {
    pub fn new(
        cause: &str,
        message: &str,
    ) -> Self {
        Self {
            status_code: 500,
            cause: cause.to_string(),
            message: Some(message.to_string()),
        }
    }
}

impl std::error::Error for OutboxPatternProcessorError {}

impl fmt::Display for OutboxPatternProcessorError {
    fn fmt(
        &self,
        f: &mut fmt::Formatter<'_>,
    ) -> fmt::Result {
        write!(f, "{}", self.cause)
    }
}