Skip to content

gh-122163: Add notes for JSON serialization errors #122165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 23, 2024

This allows to identify the source of the error.


📚 Documentation preview 📚: https://cpython-previews--122165.org.readthedocs.build/

This allows to identify the source of the error.
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@serhiy-storchaka serhiy-storchaka merged commit e6b25e9 into python:main Jul 23, 2024
40 checks passed
@serhiy-storchaka serhiy-storchaka deleted the json-encode-notes branch July 23, 2024 17:02
nohlson pushed a commit to nohlson/cpython that referenced this pull request Jul 24, 2024
nohlson pushed a commit to nohlson/cpython that referenced this pull request Jul 24, 2024
@nineteendo
Copy link
Contributor

Serhiy, how can I do this in a third party library? _PyErr_FormatNote() is not part of the public API.
Or should I use a different approach? Like creating a JSON path. "/foos/1/bar" and adding it to the error message.

@serhiy-storchaka
Copy link
Member Author

You can do this by implementing your own _PyErr_FormatNote() or like. Create a string object and call the add_note() method of the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants