From: mcsun!sunic!news.lth.se!dag@uunet.uu.net (Dag Bruck)
Subject: Re: Comparison of Ada and C++ exceptions?
Date: 16 Sep 93 06:20:30 GMT [thread overview]
Message-ID: <2790je$4en@nic.lth.se> (raw)
In <comp.lang.ada> Dale Stanbrough <dale@goanna.cs.rmit.edu.au> 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
next reply other threads:[~1993-09-16 6:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-09-16 6:20 Dag Bruck [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-09-19 21:39 Comparison of Ada and C++ exceptions? agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!d
1993-09-16 14:28 David Emery
1993-09-16 8:45 pipex!zaphod.crihan.fr!vishnu.jussieu.fr!univ-lyon1.fr!scsing.switch.ch!e
1993-09-15 1:03 munnari.oz.au!bruce.cs.monash.edu.au!monu6!aggedor.rmit.OZ.AU!root
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox