r/cpp • u/pavel_v • Apr 02 '26
What happens when a destructor throws
https://www.sandordargo.com/blog/2026/04/01/when-a-destructor-throws
102
Upvotes
r/cpp • u/pavel_v • Apr 02 '26
View all comments
Show parent comment
3
u/canadajones68 Apr 02 '26
The thing is, exceptions let the API consumer decide where the error checking goes. If you don't use exceptions, every possible error must be manually propagated up the chain of functions. With exceptions, you just write your happy path and it works. That's not to say exceptions are the best mechanism for all error reporting, but it is well-suited for the case where trying to ensure that an operation won't fail beforehand is a substantial portion of doing the operation.