Display exception notes when raising `ClickException`
Open
Nobody has claimed this yet.
parsing
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
Since 3.11 Python supports adding notes on exceptions. Basically this is completion of the exception message, and it can be useful to add context.
Notes are currently not displayed when ClickException are raised:
import click
@click.command()
def foobar():
exc = click.ClickException("foo")
exc.add_note("bar")
raise exc
if __name__ == '__main__':
foobar()
$ python foobar.py
Error: foo
I suggest to display the notes in addition to the main message.
What do you think?
Contributor guide
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 by running the foobar.py example from the issue and trace how ClickException is rendered by the CLI. Done means exception notes added with add_note are displayed in addition to the main Error: foo message, with coverage for the demonstrated behavior.
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
- 42/100