From 172f8163139f8112b76d462198a1213a5cb49dde Mon Sep 17 00:00:00 2001 From: Gus Power Date: Sat, 7 Jun 2025 14:55:21 +0100 Subject: first test of Junie - add network module for detecting available network adapters --- src/error.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 1ce9482..1b71511 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,5 @@ use homedir::GetHomeError; +use network_interface::Error as NetworkInterfaceError; use reqwest::{Error as ReqwestError, Url}; use serde_json::Error as JsonError; use std::fmt; @@ -16,6 +17,7 @@ pub enum AppError { InvalidResponse { url: Url, reason: String }, InvalidHttpHeader(String), UnableToGetHomeDirectory(GetHomeError), + NetworkInterfaceError(NetworkInterfaceError), } impl fmt::Display for AppError { @@ -34,11 +36,16 @@ impl fmt::Display for AppError { Self::RequestFailed { url, .. } => write!(f, "Request to {} failed", url), Self::InvalidResponse { url, reason } => { write!(f, "Invalid response from {}: {}", url, reason) - }, - Self::InvalidHttpHeader(message) => write!(f, "Invalid HTTP header configuration: {}", message), + } + Self::InvalidHttpHeader(message) => { + write!(f, "Invalid HTTP header configuration: {}", message) + } Self::UnableToGetHomeDirectory(err) => { write!(f, "Failed to get home directory: {}", err) } + Self::NetworkInterfaceError(err) => { + write!(f, "Network interface error: {}", err) + } } } } @@ -49,6 +56,7 @@ impl std::error::Error for AppError { Self::IoError(err) => Some(err), Self::ConfigParseError { source, .. } => Some(source), Self::RequestFailed { source, .. } => Some(source), + Self::NetworkInterfaceError(err) => Some(err), _ => None, } } -- cgit v1.2.3