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 32,402 of 33,346   
   Zeljko Vrba to goran.pusic@gmail.com   
   Re: Will we ever be able to throw from a   
   11 Jun 12 10:59:37   
   
   From: mordor.nospam@fly.srk.fer.hr   
      
   On 2012-06-11, goran.pusic@gmail.com  wrote:   
      
   > So... How do you handle fclose failure? (Captain Obvious: current code   
   > does squat)   
      
   Write data to some other location.  [Actually, regardless of whether   
   (f)close succeeds, the resources are freed.  Return code tells you   
   that you might want to write data anew.]   
      
   > 2. store it where? you already on a cleanup path, so that storing   
   >     better be a no-fail operation; if you do similar things regularly,   
   >     that's a tough call.   
      
   A global error-stack, for example, and let the caller inspect and   
   clear the stack at convenience.  That's what OpenSSL does; it migt   
   anyway be a more sane way of error-handling than exceptions.  Use   
   destructors for convenience (RAII), use error-stack for reporting   
   errors, use exceptions to report errors that aren't meant to be   
   handled.   
      
      
   > You DON'T, EVER, try to "return" failure on a cleanup path, either   
   > through an exception, or a retval.   
      
   Misunderstanding "cleanup" may be the culprit of this discussion:   
   if you care about success/failure of some operation, it's not   
   cleanup and doesn't belong in the destructor.   
      
      
   --   
         [ 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