title: Pattern to avoid nested try catch blocks?
body: <p>Consider a situation where I have three (or more) ways of performing a calculation, each of which can fail with an exception. In order to attempt each calculation until we find one that succeeds, I have been doing the following:</p>
  
  <pre><code>double val;
  
  try { val = calc1(); }
  catch (Calc1Exception e1)
  { 
      try { val = calc2(); }
      catch (Calc2Exception e2)
      {
          try { val = calc3(); }
          catch (Calc3Exception e3)
          {
              throw new NoCalcsWorkedException();
          }
      }
  }
  </code></pre>
  
  <p>Is there any accepted pattern which achieves this in a nicer way? Of course I could wrap each calculation in a helper method which returns null on failure, and then just use the <code>??</code> operator, but is there a way of doing this more generally (i.e. without having to write a helper method for each method I want to use)? I've thought about writing a static method using generics which wraps any given method in a try/catch and returns null on failure, but I'm not sure how I would go about this. Any ideas?</p>