home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,625 of 33,346   
   Francis Glassborow to Dave Abrahams   
   Re: Looking for an elegant way to conver   
   05 Nov 11 14:18:45   
   
   From: francis.glassborow@btinternet.com   
      
   On 05/11/2011 05:13, Dave Abrahams wrote:   
   > on Thu Nov 03 2011, Castor Nageur  wrote:   
   >   
   >> Hi all,   
   >>   
   >> I am using an API exporting many classes and each class export many   
   >> methods.  Each method is throwing some "APIException" exception   
   >> instance when something goes wrong.  We are not very happy with this   
   >> because our developpers use to forgetting catching the exceptions so   
   >> many applications crash because of this.   
   >   
   > Writing exception-safe code is not about catching exceptions; it's about   
   > maintaining invariants.  If your applications are crashing the cure is   
   > almost certainly not (primarily) to add more catch blocks.  Usually one   
   > catch block at the outer level of an application (in its "main loop") is   
   > sufficient.   
   >   
      
   Good catch. Too many mediocre programmers do not realise that exceptions   
   are not just another way to handle error situations but deliver useful   
   resource handling. Yes you can do it all with error codes but I will bet   
   that any programmer who wants to use error codes instead of exceptions   
   will write code that leaks like a sieve (and the leaks will not just be   
   memory but scarce resources as well)   
      
   There is a great deal more to replacing exceptions with error codes and   
   most of it is tedious hard work. (It is much easier to go the other way)   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca