3 ms·
I'm sorry, I can't capture such a complicated issue with a pithy example. You will have to settle for my illustrative one. The most general definition of the r
by gakada 10y ago
I'm sorry, I can't capture such a complicated issue with a pithy example. You will have to settle for my illustrative one.
The most general definition of the restriction is that C++ code cannot throw exceptions through exception unsafe code. How do you know if your C++ function was called from exception unsafe code? You can't!
So it's only ever safe to throw an exception when you are expecting it to be caught immediately i.e. you can use exceptions as glorified error codes, but not much else.
In Django I can throw a Http404 exception from deep inside a view and the server will come up with a 404 response. I can assert and the client will get a 500 error but the server won't go down. This is the real power of exceptions, and God help anybody who tries to do it in C++.