set_username: replace some unwraps with recovery paths + logging

i don't actually know much about this path: an `expect` might make more
sense. i'm just trying to make this more debuggable.
This commit is contained in:
2022-10-20 19:10:25 -07:00
parent 37040526b9
commit ce4a58c82b

View File

@@ -160,9 +160,15 @@ impl Handler {
fn set_username(&mut self) { fn set_username(&mut self) {
if let Some(user_list) = lightdm::UserList::get_instance() { if let Some(user_list) = lightdm::UserList::get_instance() {
if let Some(name) = user_list.get_users().first().unwrap().get_name() { match user_list.get_users().first() {
let name_str = Box::<str>::from(name); Some(user) => match user.get_name() {
self.user = Some(String::from(name_str)); Some(name) => {
let name_str = Box::<str>::from(name);
self.user = Some(String::from(name_str));
},
None => log::warn!("user.get_name() returned None"),
},
None => log::warn!("user_list.get_users() returned empty"),
}; };
} }
} }