[code] better error handling and show available netdevs on some errors
This commit is contained in:
+8
-1
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user