Improve error handling

This commit is contained in:
Nils Andreas Svee committed 2022-09-29 00:25:14 +02:00
1 parent e4f7b301b5
commit 4d4ecd1289
1 file changed
+4 -4
+4 -4
View File
@@ -106,7 +106,7 @@ impl Netlink {
} }
// we shouldn't reach here // we shouldn't reach here
Ok(-1) Err(Box::new(NlError::msg("Netlink error retrieving link")))
} }
pub fn get_interface_stats(ifname: &str) -> Result<RtnlLinkStats64, Box<dyn Error>> { pub fn get_interface_stats(ifname: &str) -> Result<RtnlLinkStats64, Box<dyn Error>> {
@@ -205,13 +205,13 @@ impl Netlink {
} }
pub fn set_qdisc_rate(qdisc: Qdisc, bandwidth_kbit: u64) -> Result<(), Box<dyn Error>> { pub fn set_qdisc_rate(qdisc: Qdisc, bandwidth_kbit: u64) -> Result<(), Box<dyn Error>> {
let mut socket = NlSocketHandle::connect(NlFamily::Route, None, &[]).unwrap(); let mut socket = NlSocketHandle::connect(NlFamily::Route, None, &[])?;
let bandwidth = bandwidth_kbit * 1000 / 8; let bandwidth = bandwidth_kbit * 1000 / 8;
let mut attrs = RtBuffer::new(); let mut attrs = RtBuffer::new();
let attr_type = Rtattr::new(None, Tca::Kind, "cake").unwrap(); let attr_type = Rtattr::new(None, Tca::Kind, "cake")?;
let mut attr_options = Rtattr::new(None, Tca::Options, Buffer::from(Vec::new())).unwrap(); let mut attr_options = Rtattr::new(None, Tca::Options, Buffer::from(Vec::new()))?;
attr_options.add_nested_attribute(&Rtattr::new( attr_options.add_nested_attribute(&Rtattr::new(
None, None,
TcaCake::BaseRate64 as u16, TcaCake::BaseRate64 as u16,