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,c4bd2a19251049b1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: best practice: error handling Date: Sun, 12 Jun 2011 00:19:58 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <0b95a2a1-6e3d-4ad1-a832-e3099a9bce37@v8g2000yqb.googlegroups.com> <1ulcworf418ai$.iy0mm08iuusy.dlg@40tude.net> <1835s5a847r9q$.191jzvxwbypk8.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1307856010 32456 69.95.181.76 (12 Jun 2011 05:20:10 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sun, 12 Jun 2011 05:20:10 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6090 Xref: g2news2.google.com comp.lang.ada:20736 Date: 2011-06-12T00:19:58-05:00 List-Id: "Dmitry A. Kazakov" 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.