[code] better error handling and show available netdevs on some errors

This commit is contained in:
2025-03-14 01:09:03 +01:00
parent 3963bce64e
commit a03a679f71
3 changed files with 79 additions and 9 deletions
+8 -1
View File
@@ -6,6 +6,8 @@ mod sysfs;
use std::{env, thread::sleep};
use sysfs::NetdevError;
use crate::{cfg::Config, measure::LinkSpeed};
fn main() -> eyre::Result<()> {
@@ -19,7 +21,12 @@ fn main() -> eyre::Result<()> {
(Some(_), Some(na)) => na,
(Some(nc), None) => nc,
(None, Some(na)) => na,
(None, None) => eyre::bail!("No network device specified"),
(None, None) => {
eyre::bail!(
"No network device specified. Please provide a network device name as an argument or in the config file.\n\n{}",
NetdevError::available_netdevs_msg()
);
}
};
let link_speed = LinkSpeed::new(&netdev_name)?;