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)   
|