amqp_api_client/
error.rs

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