Skip to content

Add support for "Exception.add_note(...)" (PEP 678) #505

@libexpand

Description

@libexpand

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

>>> try:
...     raise TypeError('bad type')
... except Exception as e:
...     e.add_note('Add some information')
...     raise
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: bad type
Add some information
>>>

Description

The note does not appear when pretty_exceptions_enable=True
PEP 678 – Enriching Exceptions with Notes

Wanted Solution

I would like the note to appear when pretty exceptions are enabled.

Wanted Code

try:
    raise TypeError('bad type')
except Exception as e:
    e.add_note('Add some information')
    raise

Alternatives

No response

Operating System

Linux, Windows

Operating System Details

No response

Typer Version

0.7.0

Python Version

Python 3.11.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions