1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

fix: add explicit failure message for DBus property downcasting

This commit is contained in:
Reinout Meliesie 2024-03-31 22:45:24 +02:00
parent 68ca8da302
commit c41d37ca38
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6

View file

@ -133,12 +133,12 @@ async fn get_network_state(
let primary_connection_path = properties["PrimaryConnection"]
.downcast_ref::<ObjectPath>()
.unwrap();
.expect("PrimaryConnection was not an object path, violation of NetworkManager D-Bus interface");
if primary_connection_path != "/" {
let primary_connection_type = properties["PrimaryConnectionType"]
.downcast_ref::<str>()
.unwrap()
.expect("PrimaryConnectionType was not a string, violation of NetworkManager D-Bus interface")
.to_string();
match primary_connection_type.as_str() {
@ -159,7 +159,7 @@ async fn get_network_state(
} else {
let wireless_enabled = *properties["WirelessEnabled"]
.downcast_ref::<bool>()
.unwrap();
.expect("WirelessEnabled was not a boolean, violation of NetworkManager D-Bus interface");
if wireless_enabled {
Ok(NetworkManagerState::WirelessDisconnected)
} else {