title: java - Managing duplicate code in multiple catch blocks
body: <p>I have the following code</p>
  
  <pre><code>    try {
          // code
      } catch (Exception1 e1) {
          if (condition) {
              //code
          } else {
              throw e1;
          }
      } catch (Exception2 e2) {
          if (condition) {
              //code
          } else {
              throw e2;
          }
      }
  </code></pre>
  
  <p>How can I use a private method to modularize the if-else block in both the catches. </p>
  
  <p>More specifically, if i use a method how to pass the different exceptions to the method and throw them appropriately?</p>
  
  <p>I followed this <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html" rel="nofollow">link</a>, but did not understand how to pass and throw the right exceptions.</p>