amqp_api_shared/
error.rs

1use std::fmt;
2
3#[derive(Debug, Copy, Clone, PartialEq)]
4pub enum ErrorKind {
5    InternalFailure,
6    ConfigFailure,
7    StateUpdateFailure,
8}
9
10#[derive(Debug, Clone, PartialEq)]
11pub struct Error {
12    pub kind: ErrorKind,
13    pub message: String,
14}
15
16impl Error {
17    pub fn new(kind: ErrorKind, message: impl Into<String>) -> Error {
18        Error {
19            kind,
20            message: message.into(),
21        }
22    }
23
24    pub fn kind(&self) -> ErrorKind {
25        self.kind
26    }
27}
28
29impl fmt::Display for Error {
30    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31        write!(f, "{}", self.message)
32    }
33}