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
commit 5ea6714db8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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(),