title: Guava cache and preserving checked exceptions
body: <p>I'm refactoring some code to use <a href="http://code.google.com/p/guava-libraries/wiki/CachesExplained">guava Cache</a>.</p>
  
  <p>Initial code:</p>
  
  <pre><code>public Post getPost(Integer key) throws SQLException, IOException {
      return PostsDB.findPostByID(key);
  }
  </code></pre>
  
  <p>In order not to break something I need to preserve any thrown exception as is, without wrapping it.</p>
  
  <p>Current solution appears somewhat ugly:</p>
  
  <pre><code>public Post getPost(final Integer key) throws SQLException, IOException {
      try {
          return cache.get(key, new Callable&lt;Post&gt;() {
              @Override
              public Post call() throws Exception {
                  return PostsDB.findPostByID(key);
              }
          });
      } catch (ExecutionException e) {
          Throwable cause = e.getCause();
          if (cause instanceof SQLException) {
              throw (SQLException) cause;
          } else if (cause instanceof IOException) {
              throw (IOException) cause;
          } else if (cause instanceof RuntimeException) {
              throw (RuntimeException) cause;
          } else if (cause instanceof Error) {
              throw (Error) cause;
          } else {
              throw new IllegalStateException(e);
          }
      }
  }
  </code></pre>
  
  <p>Is there any possible way to make it nicer?</p>