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