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

I have seen exactly 0 programs that ever wrapped new calls in try/catch blocks to catch bad_alloc. If you can't allocate memory, you are likely going to need to exit anyway.

You can write quite a lot of C++ without ever using exceptions since exceptions. There are people who write exception-happy code. I tend to prefer only using exceptions for exceptional events like where the the only other option would be for the program to exit. I throw an exception in the hope that someone upstream will catch it and be able to handle it.

Honestly, if you throwing exceptions constantly as part of your normal executing code path, you're going to drive yourself crazy.



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

Search: