set_username: replace some unwrap
s 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:
12
src/main.rs
12
src/main.rs
@@ -160,9 +160,15 @@ impl Handler {
|
||||
|
||||
fn set_username(&mut self) {
|
||||
if let Some(user_list) = lightdm::UserList::get_instance() {
|
||||
if let Some(name) = user_list.get_users().first().unwrap().get_name() {
|
||||
let name_str = Box::<str>::from(name);
|
||||
self.user = Some(String::from(name_str));
|
||||
match user_list.get_users().first() {
|
||||
Some(user) => match user.get_name() {
|
||||
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"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user