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,699cc914522aa7c4,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!kanaga.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Structured exception information Date: Mon, 15 Jan 2007 14:44:37 +0100 Organization: CERN News Message-ID: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Trace: cernne03.cern.ch 1168868678 2423 137.138.37.241 (15 Jan 2007 13:44:38 GMT) X-Complaints-To: news@@cern.ch NNTP-Posting-Date: Mon, 15 Jan 2007 13:44:38 +0000 (UTC) User-Agent: Thunderbird 1.5.0.9 (X11/20061220) Xref: g2news2.google.com comp.lang.ada:8134 Date: 2007-01-15T14:44:37+01:00 List-Id: Hi, Consider an object created by a constructor function: X : My_Type := My_Constructor(Some_Parameters); My_Type is Controlled_Limited to ensure control over initialization and finalization. The idea of constructor function is to prevent the existence of objects that are not yet initialized, half-baked, in a bad state, etc. If the object exists, it's ready for use. If there are problems during the execution of the constructor function, the exception is raised, so that there is no X object in a bad state. How can I pass some error information from the constructor function out, so that it's used when the exception is handled? Obviously, some message can be attached to the exception occurence, but it doesn't scale well - I might want to pass some more data, possibly structured (some error code, some reason code, some timestamp, some whatever else, ...). Yes, I'm asking for "throwing objects", in the C++ parlance. How to do this in Ada? If I cannot - how to solve this design problem? BTW - How can I ensure in a general way that the constructor function must be used to initialize the object, otherwise compile-time error is reported? If I make My_Type a discriminated type (so that the discriminant value is used in the default initialization), does it limit anything, like constructor parameter types? -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/