Using Ctrl+C to quit makes a really ugly error
nahsra opened this issue · comments
I was in pixee explain
, and I hit Ctrl+C on a codemod selection dialog. When I hit Ctrl+C to quit, I got a big, ugly Python backtrace. It gave me the squishy feeling that I did something disallowed, that I shouldn't do that again, etc. Can we make this smoother?
Cancelled by user
Traceback (most recent call last):
File "/usr/local/bin/pixee", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/Cellar/pixee/0.5.2/libexec/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pixee/0.5.2/libexec/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pixee/0.5.2/libexec/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pixee/0.5.2/libexec/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pixee/0.5.2/libexec/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/pixee/0.5.2/libexec/lib/python3.11/site-packages/pixee/cli.py", line 390, in explain
result = next(result for result in results if result["codemod"] == codemod)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration
👍 yes good catch, this is a bug. I thought the library handled KeyboardInterrupt
(and it does) but we still need to process the result.