1use std::fmt;
2
3pub enum AmqError {
16 UnsupportedPlatform,
17 TcpServerClosed,
18 TcpServerError(String),
19 TcpReceiveError(String),
20 TcpReceiveDataError(String),
21 TcpSendError(String),
22 TcpSendDataError(String),
23 AuthorizationError(String),
24}
25
26impl fmt::Display for AmqError {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match self {
29 AmqError::UnsupportedPlatform => write!(f, "Unsupported Platform"),
30 AmqError::TcpServerClosed => write!(f, "TCP Server Closed"),
31 AmqError::TcpServerError(s) => write!(f, "TCP Server Error: {}", s),
32 AmqError::TcpReceiveError(s) => write!(f, "TCP Receive Error: {}", s),
33 AmqError::TcpReceiveDataError(s) => write!(f, "TCP Receive Data Error: {}", s),
34 AmqError::TcpSendError(s) => write!(f, "TCP Send Error: {}", s),
35 AmqError::TcpSendDataError(s) => write!(f, "TCP Send Data Error: {}", s),
36 AmqError::AuthorizationError(s) => write!(f, "Authorization Error: {}", s),
37 }
38 }
39}
40
41impl fmt::Debug for AmqError {
42 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
43 match self {
44 AmqError::UnsupportedPlatform => write!(f, "Unsupported Platform"),
45 AmqError::TcpServerClosed => write!(f, "TCP Server Closed"),
46 AmqError::TcpServerError(s) => write!(f, "TCP Server Error: {}", s),
47 AmqError::TcpReceiveError(s) => write!(f, "TCP Receive Error: {}", s),
48 AmqError::TcpReceiveDataError(s) => write!(f, "TCP Receive Data Error: {}", s),
49 AmqError::TcpSendError(s) => write!(f, "TCP Send Error: {}", s),
50 AmqError::TcpSendDataError(s) => write!(f, "TCP Send Data Error: {}", s),
51 AmqError::AuthorizationError(s) => write!(f, "Authorization Error: {}", s),
52 }
53 }
54}
55
56impl std::error::Error for AmqError {}