2021-03-25 14:17:41 +01:00
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum FriendlyDescritionParseError {
|
|
|
|
#[error("unsupported header")]
|
|
|
|
UnsupportedHeader(String),
|
|
|
|
|
|
|
|
#[error("json parse error")]
|
|
|
|
SerdeJsonError(#[from] serde_json::Error),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Error)]
|
2019-06-09 20:09:06 +02:00
|
|
|
pub enum PeerEntryParseError {
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("PublicKey entry not found in lines: {:?}", lines)]
|
2019-05-17 10:17:06 +02:00
|
|
|
PublicKeyNotFound { lines: Vec<String> },
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("AllowedIPs entry not found in lines: {:?}", lines)]
|
2019-05-17 10:17:06 +02:00
|
|
|
AllowedIPsEntryNotFound { lines: Vec<String> },
|
2021-03-25 14:17:41 +01:00
|
|
|
|
|
|
|
#[error("Friendly description parse error")]
|
|
|
|
FriendlyDescritionParseError(#[from] FriendlyDescritionParseError),
|
2019-05-17 10:17:06 +02:00
|
|
|
}
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[derive(Debug, Error)]
|
2019-06-09 20:09:06 +02:00
|
|
|
pub enum ExporterError {
|
2019-04-23 23:06:35 +02:00
|
|
|
#[allow(dead_code)]
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("Generic error")]
|
2019-04-23 23:06:35 +02:00
|
|
|
Generic {},
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("Hyper error: {}", e)]
|
|
|
|
Hyper { e: hyper::Error },
|
2019-04-23 23:06:35 +02:00
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("http error: {}", e)]
|
2019-04-23 23:06:35 +02:00
|
|
|
Http { e: http::Error },
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("UTF-8 error: {}", e)]
|
2019-04-23 23:06:35 +02:00
|
|
|
UTF8 { e: std::string::FromUtf8Error },
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("JSON format error: {}", e)]
|
2019-04-23 23:06:35 +02:00
|
|
|
JSON { e: serde_json::error::Error },
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("IO Error: {}", e)]
|
2019-04-23 23:06:35 +02:00
|
|
|
IO { e: std::io::Error },
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("UTF8 conversion error: {}", e)]
|
2019-04-23 23:06:35 +02:00
|
|
|
Utf8 { e: std::str::Utf8Error },
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("int conversion error: {}", e)]
|
2019-04-23 23:06:35 +02:00
|
|
|
ParseInt { e: std::num::ParseIntError },
|
2019-05-17 10:17:06 +02:00
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
#[error("PeerEntry parse error: {}", e)]
|
2019-05-17 10:17:06 +02:00
|
|
|
PeerEntryParseError { e: PeerEntryParseError },
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<PeerEntryParseError> for ExporterError {
|
|
|
|
fn from(e: PeerEntryParseError) -> Self {
|
|
|
|
ExporterError::PeerEntryParseError { e }
|
|
|
|
}
|
2019-04-23 23:06:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::io::Error> for ExporterError {
|
|
|
|
fn from(e: std::io::Error) -> Self {
|
|
|
|
ExporterError::IO { e }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 14:17:41 +01:00
|
|
|
impl From<hyper::Error> for ExporterError {
|
|
|
|
fn from(e: hyper::Error) -> Self {
|
2019-04-23 23:06:35 +02:00
|
|
|
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 }
|
|
|
|
}
|
|
|
|
}
|