comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: best practice: error handling
Date: Sun, 12 Jun 2011 00:19:58 -0500
Date: 2011-06-12T00:19:58-05:00	[thread overview]
Message-ID: <it1ia9$vm8$1@munin.nbi.dk> (raw)
In-Reply-To: 1835s5a847r9q$.191jzvxwbypk8.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:1835s5a847r9q$.191jzvxwbypk8.dlg@40tude.net...
...
> BTW, I prefer exceptions to any kind of special values. But as Jeff Carter
> said, there can be gray zones where special values meaning "not so
> exceptional" can be used.

I generally agree. But there are sometimes cases to the contrary. With Claw, 
we originally raised an exception when the Find routine did not find the 
menu entry, window, or whatever it was looking for. But this turned out to 
be a major pain in practice. Moreover, you can make an argument that 
"Not_Found" is not an error per-se; it is a normal result. As such, we 
changed those routines to return a special value (which does not work in 
subsequent operations). It's still possible to mistakenly use that value as 
if it was a valid object, but you'll always get an exception if you do so.

Which just shows that there is no one-size-fits-all solution to this 
problem. There is no substitute for thinking about the problem you are 
solving and how the function is going to be used.

                                 Randy.





  reply	other threads:[~2011-06-12  5:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 14:01 best practice: error handling milouz
2011-05-31 17:13 ` Vinzent Hoefler
2011-05-31 17:57   ` AdaMagica
2011-06-11 13:38   ` Yannick Duchêne (Hibou57)
2011-05-31 18:08 ` Jeffrey Carter
2011-05-31 20:02   ` Dmitry A. Kazakov
2011-05-31 20:35     ` Jeffrey Carter
2011-05-31 21:40       ` Dmitry A. Kazakov
2011-06-11 13:57     ` Yannick Duchêne (Hibou57)
2011-06-11 14:07       ` Dmitry A. Kazakov
2011-06-12  5:19         ` Randy Brukardt [this message]
2011-06-11 13:48   ` Yannick Duchêne (Hibou57)
2011-06-11 13:31 ` Yannick Duchêne (Hibou57)
2011-06-11 16:12   ` Simon Wright
2011-06-11 16:26   ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox