From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b1a1ed8b075945 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!out04b.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!uns-out.usenetserver.com!news.usenetserver.com!pc02.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Allocators and exceptions References: <1189323618.588340.87180@o80g2000hse.googlegroups.com> <1189369871.672082.162750@50g2000hsm.googlegroups.com> <1189460936.295604.143720@r29g2000hsg.googlegroups.com> <1189502377.626510.172690@22g2000hsm.googlegroups.com> From: Stephen Leake Date: Wed, 12 Sep 2007 08:29:08 -0400 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/22.1 (windows-nt) Cancel-Lock: sha1:zBdOBxVOcmGpkK2sGCbnIM/7VgQ= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 9a9a546e7db98e05e48ed24451 Xref: g2news2.google.com comp.lang.ada:1906 Date: 2007-09-12T08:29:08-04:00 List-Id: Maciej Sobczak writes: > On 11 Wrz, 11:16, "Dmitry A. Kazakov" > wrote: > >> >>> P.S. Exceptions in constructors is a bad idea. >> >> > No, it's a very good idea. Otherwise you have to deal with half-baked >> > objects, which is Even Bigger Mess (tm). >> >> This is what you get when the exception is propagated out of a constructor. > > In this case I want the constructor to be rolled back. > Without exceptions (and rollback) the only option for handling errors > in initialization of (sub)components is to leave them half-baked. The point is that the constructor itself must do the roll-back, and leave the object in a consistent state. The rule should be: Constructors should not propagate exceptions up; they must handle all exceptions internally. -- -- Stephe