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

Allow for nested exceptions #11

Open
gasse opened this issue Feb 4, 2020 · 6 comments · Fixed by #308
Open

Allow for nested exceptions #11

gasse opened this issue Feb 4, 2020 · 6 comments · Fixed by #308
Labels
type/enhancement 🚀 New feature or request

Comments

@gasse
Copy link
Member

gasse commented Feb 4, 2020

Replace Exception for std::exception in order to allow std::throw_with_nested. That would improve error messages for the users.

@AntoinePrv
Copy link
Member

AntoinePrv commented Feb 4, 2020

Exceptions inherit from std::exception, I think that should be the way to be.

class Exception : public std::exception {

std::throw_with_nested seems to be templated by any type also.
What are you trying to achieve?

You would like to change throw statements with std::throw_with_nested?

@gasse
Copy link
Member Author

gasse commented Feb 5, 2020

Good, I had not realized that !

Typically I want to be able to catch an exception triggered from SCIP, and add more information / context to it. Say, I am trying to access a SCIP parameter, and a SCIP Exception is thrown: SCIP_RETCODE -12: The parameter with the given name was not found. Then I would like to re-throw the Exception but indicate the name of the parameter that was accessed. I guess std::throw_with_nested is what I want in this situation.

@AntoinePrv
Copy link
Member

So basically, we need to change all throws, to std::throw_with_nested.
In the example of the std doc, it seems special care is needed then to print them.
Is this something by automtically when an uncaught exception causes the program to terminate?
Or done automatically by pybind?

@gasse
Copy link
Member Author

gasse commented Feb 6, 2020

In my last experiments it seems pybind does not process nested exceptions the way I want, as it only prints the lastly thrown exception... Maybe not the way to go then.

@AntoinePrv
Copy link
Member

There is on open issue: pybind/pybind11#1913

@AntoinePrv AntoinePrv added the type/enhancement 🚀 New feature or request label Apr 3, 2020
@AntoinePrv
Copy link
Member

Would be useful as well if Catch2 was able to unroll nested exceptions.

@Skylion007 Skylion007 mentioned this issue Feb 3, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement 🚀 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants