2019-05-17 08:17:06 +00:00
|
|
|
#[derive(Debug, Fail)]
|
2019-06-09 18:09:06 +00:00
|
|
|
pub enum PeerEntryParseError {
|
2019-05-17 08:17:06 +00:00
|
|
|
#[fail(display = "PublicKey entry not found in lines: {:?}", lines)]
|
|
|
|
PublicKeyNotFound { lines: Vec<String> },
|
|
|
|
|
|
|
|
#[fail(display = "AllowedIPs entry not found in lines: {:?}", lines)]
|
|
|
|
AllowedIPsEntryNotFound { lines: Vec<String> },
|
|
|
|
}
|
|
|
|
|
2019-04-23 21:06:35 +00:00
|
|
|
#[derive(Debug, Fail)]
|
2019-06-09 18:09:06 +00:00
|
|
|
pub enum ExporterError {
|
2019-04-23 21:06:35 +00:00
|
|
|
#[allow(dead_code)]
|
|
|
|
#[fail(display = "Generic error")]
|
|
|
|
Generic {},
|
|
|
|
|
|
|
|
#[fail(display = "Hyper error: {}", e)]
|
|
|
|
Hyper { e: hyper::error::Error },
|
|
|
|
|
|
|
|
#[fail(display = "http error: {}", e)]
|
|
|
|
Http { e: http::Error },
|
|
|
|
|
|
|
|
#[fail(display = "UTF-8 error: {}", e)]
|
|
|
|
UTF8 { e: std::string::FromUtf8Error },
|
|
|
|
|
|
|
|
#[fail(display = "JSON format error: {}", e)]
|
|
|
|
JSON { e: serde_json::error::Error },
|
|
|
|
|
|
|
|
#[fail(display = "IO Error: {}", e)]
|
|
|
|
IO { e: std::io::Error },
|
|
|
|
|
|
|
|
#[fail(display = "UTF8 conversion error: {}", e)]
|
|
|
|
Utf8 { e: std::str::Utf8Error },
|
|
|
|
|
|
|
|
#[fail(display = "int conversion error: {}", e)]
|
|
|
|
ParseInt { e: std::num::ParseIntError },
|
2019-05-17 08:17:06 +00:00
|
|
|
|
|
|
|
#[fail(display = "PeerEntry parse error: {}", e)]
|
|
|
|
PeerEntryParseError { e: PeerEntryParseError },
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<PeerEntryParseError> for ExporterError {
|
|
|
|
fn from(e: PeerEntryParseError) -> Self {
|
|
|
|
ExporterError::PeerEntryParseError { e }
|
|
|
|
}
|
2019-04-23 21:06:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::io::Error> for ExporterError {
|
|
|
|
fn from(e: std::io::Error) -> Self {
|
|
|
|
ExporterError::IO { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<hyper::error::Error> for ExporterError {
|
|
|
|
fn from(e: hyper::error::Error) -> Self {
|
|
|
|
ExporterError::Hyper { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<http::Error> for ExporterError {
|
|
|
|
fn from(e: http::Error) -> Self {
|
|
|
|
ExporterError::Http { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::string::FromUtf8Error> for ExporterError {
|
|
|
|
fn from(e: std::string::FromUtf8Error) -> Self {
|
|
|
|
ExporterError::UTF8 { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<serde_json::error::Error> for ExporterError {
|
|
|
|
fn from(e: serde_json::error::Error) -> Self {
|
|
|
|
ExporterError::JSON { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::str::Utf8Error> for ExporterError {
|
|
|
|
fn from(e: std::str::Utf8Error) -> Self {
|
|
|
|
ExporterError::Utf8 { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::num::ParseIntError> for ExporterError {
|
|
|
|
fn from(e: std::num::ParseIntError) -> Self {
|
|
|
|
ExporterError::ParseInt { e }
|
|
|
|
}
|
|
|
|
}
|