Hacker News new | ask | show | jobs
by _b 1572 days ago
Don't write constructors that can fail unless it is failure that would be appropriate to crash for. That works out a lot better than it might naively sound. It is hard for people to reason about the possibility of constructors/destructors failing, so actually rather nice to just forbid it.
1 comments

And for those super-rare cases where it's appropriate to crash / fail hard in a constructor but you still have requirements about reporting or even recovery... setjmp/longjmp still exist.
You have always had the choice available to do something overwhelmingly worse than throwing. That is not a reason to do it.