68cf6b4b   
   From: musiphil@bawi.org   
      
   On 2012-05-10 11:48, Agents Marlow wrote:   
   > On May 9, 11:03 pm, Wil Evers wrote:   
   >> First, there is 'logic_error', which is based on the belief that it   
   >> makes sense to use exceptions to report errors in the program's   
   >> logic. C++ has a much better way of dealing with logic errors:   
   >> emit a diagnostic and abort.   
   >   
   > That is not acceptable in some situations. I worked on a very large   
   > server app where each function offered by the server was relatively   
   > isolated. With your approach a logic error in one server function   
   > would bring down the entire server and severe the connection to all   
   > its clients. So that our function never did this we used an   
   > exception that meant 'an assertion has failed'. It inherited from   
   > std::logic_error. We caught it at the entry to our function, where   
   > we reported it then exited our function. Users would report that   
   > their command failed but the server itself did not fail.   
      
   If keeping the server running is an important goal, you cannot really   
   rely on the assumption that all logic errors, a.k.a. bugs, are   
   properly detected and handled by C++ exceptions, can you? For example,   
   a simple segmentation fault will crash the entire program no matter   
   whether you use exceptions or assertions for other logic errors; a   
   subtler bug in serving a client may have corrupted data related to   
   other clients before an exception is thrown and the function is   
   terminated; etc.   
      
   Therefore, you need to build a structure based on a lower-level   
   assumption; for example, assuming on the OS level that a process will   
   not be affected by bad behaviour of another process, you can have a   
   parent process run a loop and fork child processes, which should not   
   be affected by others. I have worked in a project where a program   
   forks for a certain sub-task, not because it needs parallelism, but   
   just because sometimes it may crash from using up the stack.   
      
   --   
   Seungbeom Kim   
      
      
    [ 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)   
|