Fix: replace unwrap() with proper error handling in CLI password prompt (#14910)

Signed-off-by: bunnysayzz <stfuazzo@gmail.com>
This commit is contained in:
Azhar
2026-04-26 18:58:05 +05:30
committed by GitHub
parent 3a1622e8b5
commit 5ea6714db8

View File

@@ -25,7 +25,13 @@ impl Session {
pub fn new(id: &str, sender: mpsc::UnboundedSender<Data>) -> Self {
let mut password = "".to_owned();
if PeerConfig::load(id).password.is_empty() {
password = rpassword::prompt_password("Enter password: ").unwrap();
match rpassword::prompt_password("Enter password: ") {
Ok(p) => password = p,
Err(e) => {
log::error!("Failed to read password: {:?}", e);
password = "".to_owned();
}
}
}
let session = Self {
id: id.to_owned(),