Skip to content

Commit

Permalink
Add network error to type
Browse files Browse the repository at this point in the history
  • Loading branch information
nyonson committed Apr 6, 2024
1 parent 839c5f0 commit defb517
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const VERSION_COMMAND: [u8; 12] = [
pub enum Error {
WrongNetwork,
WrongCommand,
Network,
Network(std::io::Error),
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::WrongNetwork => write!(f, "Recieved message on wrong network"),
Error::Network => write!(f, "Network error"),
Error::Network(e) => write!(f, "Network error {}", e),
Error::WrongCommand => write!(f, "Recieved message with wrong command"),
}
}
Expand All @@ -45,7 +45,7 @@ impl fmt::Display for Error {
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::Network => None,
Error::Network(e) => Some(e),
Error::WrongNetwork => None,
Error::WrongCommand => None,
}
Expand All @@ -54,8 +54,8 @@ impl std::error::Error for Error {

// Convert IO errors.
impl From<std::io::Error> for Error {
fn from(_: std::io::Error) -> Self {
Error::Network
fn from(e: std::io::Error) -> Self {
Error::Network(e)
}
}

Expand Down

0 comments on commit defb517

Please sign in to comment.