From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 16 Sep 93 06:20:30 GMT From: mcsun!sunic!news.lth.se!dag@uunet.uu.net (Dag Bruck) Subject: Re: Comparison of Ada and C++ exceptions? Message-ID: <2790je$4en@nic.lth.se> List-Id: In Dale Stanbrough writes: >Recently I had reason to look at C++'s exception handling. I noticed that >each >exception can have associated with it some data (user defined), such as a >string, a pointer - in fact any object the programmer wants. The C++ exception is an object, and I have often wanted to pass along some information that describes the problem. Cf. the UNIX "exception" type that is used for problems detected in math routines. The exception-is-an-object idea also has the benefit that you can group exceptions by inheritance. If you have class MATHERROR .... class OVERFLOW : public MATHERROR .... class ZERODIVIDE : public MATHERROR .... class DOMAINERROR : public MATHERROR .... You can either decide to catch overflows separately, or any math error, or a combination thereof: catch (OVERFLOW) .... catch (MATHERROR) .... -- other math errors This is quite nice. -- Dag