-
Notifications
You must be signed in to change notification settings - Fork 747
Closed
Description
I accidentally returned an internal type instead of a str from my custom completer and got this exception:
Traceback (most recent call last):
File "doc_prompt_toolkit.py", line 25, in <module>
text = prompt('Column', completer=completer, bottom_toolbar='. to see shortcuts, ( to see constructor arguments')
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 803, in prompt
return session.prompt(*a, **kw)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 731, in prompt
return run_sync()
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 715, in run_sync
return self.app.run(inputhook=self.inputhook, pre_run=pre_run)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 682, in run
return run()
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 656, in run
return f.result()
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/eventloop/future.py", line 149, in result
raise self._exception
AssertionError
The original assertion error stack trace is lost. So I fiddled with the code and made it not catch this exception and store it and then I got:
Traceback (most recent call last):
File "doc_prompt_toolkit.py", line 27, in <module>
text = prompt('Column', completer=completer, bottom_toolbar='. to see shortcuts, ( to see constructor arguments')
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 803, in prompt
return session.prompt(*a, **kw)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 731, in prompt
return run_sync()
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 715, in run_sync
return self.app.run(inputhook=self.inputhook, pre_run=pre_run)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 682, in run
return run()
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 654, in run
f = self.run_async(pre_run=pre_run)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 640, in run_async
return ensure_future(_run_async2())
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/eventloop/coroutine.py", line 21, in ensure_future
return _run_coroutine(future_or_coroutine)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/eventloop/coroutine.py", line 115, in _run_coroutine
step_next()
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/eventloop/coroutine.py", line 104, in step_next
ref.future.set_exception(e)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
new_f = coroutine.send(None)
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 637, in _run_async2
assert not self._is_running
AssertionError
This isn't very helpful either, the original exception is still gone! So I commented out this assertion and then I got the real error:
File "/Users/andersh/Projects/tri.table/venv/lib/python2.7/site-packages/prompt_toolkit/formatted_text/base.py", line 50, in to_formatted_text
'HTML, ANSI or a FormattedText instance. Got %r' % value)
ValueError: No formatted text. Expecting a unicode object, HTML, ANSI or a FormattedText instance. Got 'Column'
That error message is very helpful but it was very hard to get to it. It would have been better to print that exception and stack trace and directly doing exit(1) for example.
Metadata
Metadata
Assignees
Labels
No labels