How to wrap checked exceptions but keep the original runtime exceptions in Java : <p>I have some code that might throw both checked and runtime exceptions.</p>

<p>I'd like to catch the checked exception and wrap it with a runtime exception. But if a RuntimeException is thrown, I don't have to wrap it as it's already a runtime exception.</p>

<p>The solution I have has a bit overhead and isn't "neat":</p>

<pre><code>try {
  // some code that can throw both checked and runtime exception
} catch (RuntimeException e) {
  throw e;
} catch (Exception e) {
  throw new RuntimeException(e);
}
</code></pre>

<p><strong>Any idea for a more elegant way?</strong></p>
