Skip to content

Commit

Permalink
fix: handle out-of-range choices
Browse files Browse the repository at this point in the history
Previously, error handling for choice prompts only covered non-int
values. This fix prevents out-of-range values from throwing an
exception. Fixes #91.
  • Loading branch information
squattingmonk committed Dec 28, 2021
1 parent e65cef1 commit 6619369
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nasher/utils/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ proc choose*(question: string, choices: openarray[string]): string =
except IOError:
result = choices[0]
echo result
except ValueError:
except ValueError, IndexDefect:
if stdin.isatty:
error("not a valid choice")
result = choose(question, choices)
Expand Down

0 comments on commit 6619369

Please sign in to comment.