prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Feature request: Handle `__cause__` and `__context__` in Application._handle_exception
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Application._handle_exception is used to print uncaught exceptions when running a full screen application. However if the thrown exception has a __cause__ set, such as when throwing an exception from another, e.g.:
try:
raise Exception("Inner")
except Exception as e:
raise Exception("Outer") from e
Then the inner "causing" exception is not printed. This differs from the normal exception handler in python.
It would be great if __cause__ was properly supported. There is also __context__ (when there is no explicit from) that doesn't seem to be handled either.
See also https://peps.python.org/pep-3134/#enhanced-reporting
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Application._handle_exception entry point and compare its output with Python's normal exception handler and PEP 3134. Verify handling for both explicit cause and implicit context; done means chained exceptions are printed in the full-screen application's uncaught-exception output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100