
On Thu, Oct 29, 2009 at 2:20 PM, Michael Fawcett <michael.fawcett@gmail.com> wrote:
On Thu, Oct 29, 2009 at 5:07 PM, Emil Dotchevski <emildotchevski@gmail.com> wrote:
On Thu, Oct 29, 2009 at 1:46 PM, Stewart, Robert <Robert.Stewart@sig.com> wrote:
It's simple:
if (error-not-checked && !std::uncaught_exception()) { throw something; }
I've read that article before. To me it only seemed applicable to destructors that actually did something, like a rollback. For an object that does nothing in its destructor, do you think Herb's arguments still apply?
The point is that a destructor could call a function that returns this sneaky error code object, and end up throwing an exception. You can argue that this is a bug, but that's exactly why it is evil -- for anything but a trivial toy example, such code can't reasonably be tested because it is very difficult to reproduce the conditions that could possibly lead to abort(). Why not just pick a behavior -- throw on error, or don't throw on error -- whichever is correct? Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode