diff options
| author | sigoden <sigoden@gmail.com> | 2024-02-24 19:13:48 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-24 19:13:48 +0800 |
| commit | 21d1be5bedb13d08462e9800a1c3cbf93dd585bc (patch) | |
| tree | f21874bd7fefa25fccf443df1249cdf3c74e0763 /src/utils | |
| parent | 16b7ac071f3feed52939c2244ede2f0abe5230a2 (diff) | |
| download | aichat-21d1be5bedb13d08462e9800a1c3cbf93dd585bc.tar.gz | |
refactor: improve prompt error handling (#319)
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/prompt_input.rs | 10 |
1 files changed, 4 insertions, 6 deletions
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<String> } 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<String> { @@ -36,11 +37,8 @@ pub fn prompt_input_integer(desc: &str, required: bool) -> anyhow::Result<String }) .with_help_message(MSG_OPTIONAL) } - text.prompt().map_err(prompt_op_err) -} - -pub fn prompt_op_err<T>(_: T) -> anyhow::Error { - anyhow::anyhow!("Not finish questionnaire, try again later!") + let text = text.prompt()?; + Ok(text) } #[derive(Debug, Clone, Copy)] |
