Use an exception to cancle user interactions #325
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously None was used as a return value to indicate that the user canceled but since None is also used to indicate the user made "no selection" these were not distinguishable any longer.
Before 9d02824 "q" was handled by calling sys.exit directly.
@jeffa5 the commit 9d02824 was from you. I know this is a very long time ago, but do you remember why you replaced
sys.exit
withreturn None
in theselect()
function?9d02824#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L600-R609
To me it looks like a "substitute all" mistake when replacing
sys.exit
in these places in the same commit:9d02824#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L565-R574
9d02824#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L594-R603
9d02824#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L600-R609
The commit ffbe09d reverts this and throws a custom exception if the user selects "quit". Is there any particular usage scenario where this is not acceptable?
I have tried to add more tests for the
add-email
subcomand but could not find such a use case.