Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an exception to cancle user interactions #325

Closed
wants to merge 6 commits into from
Closed

Conversation

lucc
Copy link
Owner

@lucc lucc commented Sep 23, 2023

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 with return None in the select() 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.

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.
Theoretically the SystemExit exception of the outer with block might be
caught before stdout is bound.

EditorState was unused.
@lucc lucc self-assigned this Sep 23, 2023
@lucc lucc closed this Oct 9, 2023
@lucc lucc deleted the select-errors branch October 9, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant