From c1048d6cd9651cfc2fbb56d74087a7a8f59e9a64 Mon Sep 17 00:00:00 2001 From: fdai7375 Date: Thu, 2 Feb 2023 21:10:55 +0100 Subject: [PATCH] fix: change expect to match statement --- src/builtins/logout.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/builtins/logout.rs b/src/builtins/logout.rs index ce3a450..5056e48 100644 --- a/src/builtins/logout.rs +++ b/src/builtins/logout.rs @@ -9,9 +9,14 @@ impl Builtin for Logout { fn execute(&mut self, _: &mut BuiltinConfig, _: Vec) -> Result<(), ShellError> { let mut input_confirmation = String::new(); println!("Are you sure? Unsaved data will be lost.\ny/n"); - io::stdin() - .read_line(&mut input_confirmation) - .expect("Couldn't read form stdin"); + match io::stdin().read_line(&mut input_confirmation) { + Ok(_) => {} + Err(e) => { + return Err(ShellError::ExecuteFailure(format!( + "Couldn't read from stdin. {e}", + ))); + } + } if input_confirmation.starts_with('y') { match logout() { Ok(_) => println!("Logging out"),