Quote:Original post by Giblodian
or the method I originally mentioned just seem much simpler than fiddling around with throw,try,catch everywhere.
If you're fiddling around with them, you're probably not using them the way they were "supposed" to be used. throw statements are a replacement for "return ERROR_CODE;" in many situations (though often error codes are still suitable in other places). But try/catch()es should be far less frequent than checking for errors. All in all, it should be significantly less fiddly.
Your example would also have the client fiddle around with manual resource management, too. Not to mention the fact that it could potentially throw a bad_alloc exception (and that does happen on Windows if you're creating a particularly hungry app).
I'm not saying exceptions are a silver bullet. Sometimes, they are a royal PITA. But I would suggest getting to know them better. In some ways (namely stack unwinding), C++ actually has better machinery to handle exceptions than many other languages.