title: Do you (really) write exception safe code?
body: <p>Exception handling (EH) seems to be the current standard, and by searching the web, I can not find any novel ideas or methods that try to improve or replace it (well, some variations exist, but nothing novel).</p>
  
  <p>Though most people seem to ignore it or just accept it, EH <strong>has</strong> some huge drawbacks: exceptions are invisible to the code and it creates many, many possible exit points. Joel on software wrote an <a href="http://www.joelonsoftware.com/items/2003/10/13.html" rel="noreferrer">article about it</a>. The comparison to <code>goto</code> fits perfect, it made me think again about EH.</p>
  
  <p>I try to avoid EH and just use return values, callbacks or whatever fits the purpose. But <strong>when you have to write reliable code, you just can't ignore EH these days</strong>: It starts with the <code>new</code>, which may throw an exception, instead of just returning 0 (like in the old days). This makes about any line of C++ code <em>vulnerable</em> to an exception. And then more places in the C++ foundational code throw exceptions... std lib does it, and so on.</p>
  
  <p>This feels like <strong>walking on shaky grounds</strong>.. So, now we are forced to take care about exceptions!</p>
  
  <p>But its hard, its really hard. You have to learn to write exception safe code, and even if you have some experience with it, it will still be required to double check any single line of code to be safe! Or you start to put try/catch blocks everywhere, which clutters the code until it reaches a state of unreadability.</p>
  
  <p>EH replaced the old clean deterministical approach (return values..), which had just a few but understandable and easily solveable drawbacks with an approach that creates many possible exit points in your code, and if you start writing code that catches exceptions (what you are forced to do at some point), then it even creates a multitude of paths through your code (code in the catch blocks, think about a server program where you need logging facilities other than std::cerr ..). EH has advantages, but that's not the point.</p>
  
  <p>My actual questions:</p>
  
  <ul>
  <li>Do you really write exception safe code?</li>
  <li>Are you sure your last "production ready" code is exception safe?</li>
  <li>Can you even be sure, that it is?</li>
  <li>Do you know and/or actually use alternatives that work?</li>
  </ul>