From 21d1be5bedb13d08462e9800a1c3cbf93dd585bc Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 24 Feb 2024 19:13:48 +0800 Subject: refactor: improve prompt error handling (#319) --- src/utils/prompt_input.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/utils/prompt_input.rs') diff --git a/src/utils/prompt_input.rs b/src/utils/prompt_input.rs index f63823a..e887b9f 100644 --- a/src/utils/prompt_input.rs +++ b/src/utils/prompt_input.rs @@ -10,7 +10,8 @@ pub fn prompt_input_string(desc: &str, required: bool) -> anyhow::Result } else { text = text.with_help_message(MSG_OPTIONAL) } - text.prompt().map_err(prompt_op_err) + let text = text.prompt()?; + Ok(text) } pub fn prompt_input_integer(desc: &str, required: bool) -> anyhow::Result { @@ -36,11 +37,8 @@ pub fn prompt_input_integer(desc: &str, required: bool) -> anyhow::Result(_: T) -> anyhow::Error { - anyhow::anyhow!("Not finish questionnaire, try again later!") + let text = text.prompt()?; + Ok(text) } #[derive(Debug, Clone, Copy)] -- cgit v1.2.3