diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-11-13 15:30:16 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-11-13 15:30:16 +0100 |
commit | a85725eede89f8d7fecd10dc0628a01e48cccd7d (patch) | |
tree | 2ac1b7473b95b0791552988b6f9b6294675348f2 /src/configuration/error.rs | |
parent | Work on UAPI serialize device (diff) | |
download | wireguard-rs-a85725eede89f8d7fecd10dc0628a01e48cccd7d.tar.xz wireguard-rs-a85725eede89f8d7fecd10dc0628a01e48cccd7d.zip |
Initial version of full UAPI parser
Diffstat (limited to 'src/configuration/error.rs')
-rw-r--r-- | src/configuration/error.rs | 30 |
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, } } } |