Skip to content
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

Map std::nested_exceptions to Python equivalent #1913

Closed
ingomueller-net opened this issue Sep 7, 2019 · 4 comments · Fixed by #3608
Closed

Map std::nested_exceptions to Python equivalent #1913

ingomueller-net opened this issue Sep 7, 2019 · 4 comments · Fixed by #3608

Comments

@ingomueller-net
Copy link

I want to collect ideas whether and how one could map std::nested_exceptions to Python's chained exceptions from a raise ... from clause and vice versa. These seem to be the corresponding language features in the two languages, and hence could be an interesting addition to pybind. My expectation is that this would provide more information in case of exceptions that cross language barriers.

I have done only very initial research, but if there is interest from the side of this project, I might be able to invest some more time, potentially with ideas and help from others.

@nedrebo
Copy link

nedrebo commented Sep 17, 2020

This would be really valuable for us as well since our library relies heavily on nested exceptions. An exception hierarchy in C++ typically looks like:

Higher-level context-aware message
  + Inner error with root cause details
    + More inner with gorry details
      + Even more inner
        + ...

Unfortunately, our wrapper raises a plan exceptions with only the Higher-level context-aware message message preserved. This makes it hard for end-user to root cause some types of problems.

@Skylion007
Copy link
Collaborator

We now support raise_from with PyBind11 so we really should revisit this.

@Skylion007
Copy link
Collaborator

@nedrebo @ingomueller-net Would either of you be interested in working on this? It should be doable without too much effort with using std::rethrow_if_nested and https://pybind11.readthedocs.io/en/stable/advanced/exceptions.html#chaining-exceptions-raise-from .

@Skylion007
Copy link
Collaborator

@ingomueller-net @nedrebo Just opened a PR #3608 to add support for this issue.

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

Successfully merging a pull request may close this issue.

3 participants