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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86c750b8474bf6d5 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!zen.net.uk!dedekind.zen.co.uk!peer.news.zetnet.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: About String Date: Sat, 07 Jun 2008 17:18:12 +0100 Organization: Pushface Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1212855492 940 62.49.19.209 (7 Jun 2008 16:18:12 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 7 Jun 2008 16:18:12 +0000 (UTC) Cancel-Lock: sha1:Pm2f9T/7XUMTbNol8T95cao2Evg= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin) Xref: g2news1.google.com comp.lang.ada:600 Date: 2008-06-07T17:18:12+01:00 List-Id: S�bastien Morand writes: > So the main problem is error management. If one function raise > exception, the exception can't be catch except with the following trick: I don't know why you call it a trick! Perfectly standard Ada ... > procedure Patati_Patata is > begin > declare > s: String := A_Function_Raising_Constraint_Error; > begin > -- some code > null; > end; > exception > when Constraint_Error => > Put_Line("I got an error"); > end; > > Is there nicer way to do that? I'm trying to avoid Unbounded_String > because of the conversion when mixing Unbounded_String and String. You might want to handle the problem locally: procedure Patati_Patata is begin declare S : String := A_Function_Raising_Constraint_Error; begin -- some code exception when Constraint_Error => -- deal with the problem and carry on .. end; -- .. here end Patati_Patata; In general I don't like exception handlers which output a message and then allow the procedure to look as though it has succeeded when in fact something unforeseen has occurred, and is waiting to cause mysterious problems much much later. Exceptions to this guideline could include 'last-chance' exception handlers in tasks and the main program; but if you are controlling missiles, medical equipment or money it's probably better not to just stumble on in the hope that things will turn out all right.