aboutsummaryrefslogtreecommitdiffstats
path: root/src/configuration/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/configuration/error.rs')
-rw-r--r--src/configuration/error.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/configuration/error.rs b/src/configuration/error.rs
index be08c9e..b7d7bb0 100644
--- a/src/configuration/error.rs
+++ b/src/configuration/error.rs
@@ -1,3 +1,7 @@
+use std::error::Error;
+use std::fmt;
+
+#[derive(Debug)]
pub enum ConfigError {
NoSuchPeer,
NotListening,
@@ -9,13 +13,32 @@ pub enum ConfigError {
InvalidSocketAddr,
InvalidKeepaliveInterval,
InvalidAllowedIp,
+ InvalidOperation,
+ LineTooLong,
+ IOError,
UnsupportedValue,
UnsupportedProtocolVersion,
}
+impl fmt::Display for ConfigError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "ConfigError(errno = {})", self.errno())
+ }
+}
+
+impl Error for ConfigError {
+ fn description(&self) -> &str {
+ ""
+ }
+
+ fn source(&self) -> Option<&(dyn Error + 'static)> {
+ None
+ }
+}
+
impl ConfigError {
- fn errno(&self) -> i32 {
- // TODO: obtain the correct error values
+ pub fn errno(&self) -> i32 {
+ // TODO: obtain the correct errorno values
match self {
ConfigError::NoSuchPeer => 1,
ConfigError::NotListening => 2,
@@ -26,9 +49,12 @@ impl ConfigError {
ConfigError::InvalidSocketAddr => 10,
ConfigError::InvalidKeepaliveInterval => 11,
ConfigError::InvalidAllowedIp => 12,
+ ConfigError::InvalidOperation => 15,
ConfigError::UnsupportedValue => 7,
+ ConfigError::LineTooLong => 13,
ConfigError::InvalidKey => 8,
ConfigError::UnsupportedProtocolVersion => 9,
+ ConfigError::IOError => 14,
}
}
}