Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The entire point of the article is that you cannot throw from a destructor.

You need to read the article again because your assertion is patently false. You can throw and handle exceptions in destructors. What you cannot do is not catch those exceptions, because as per the standard uncaught exceptions will lead the application to be immediately terminated.





You can throw in a destructor but not from one, as the quoted text rightly notes.

So inside a destructor throw has a radically different behaviour that makes it useless for communicating non-fatal errors

> So inside a destructor throw has a radically different behaviour that makes it useless for communicating non-fatal errors

It's weird how you tried to frame a core design feature of the most successful programming language in the history of mankind as "useless".

Perhaps the explanation lies in how you tried to claim that exceptions had any place in "communicating non-fatal errors", not to mention that your scenario, handling non-fatal errors when destroying a resource, is fundamentally meaningless.

Perhaps you should take a step back and think whether it makes sense to extrapolate your mental models to languages you're not familiar with.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: