public <S extends Exception, T extends TException> ExceptionHandler
      convertIfInstance(Class<S> source, Class<T> target) throws T {
    T targetException = null;
    if (source.isInstance(e)) {
      try {
        targetException = JavaUtils.newInstance(target,
            new Class[]{String.class}, new Object[]{e.getMessage()});
      } catch (Exception ex) {
        // This should not happen
        throw new RuntimeException(ex);
      }
    }
    if (targetException != null) {
      throw targetException;
    }
    return this;
  }
Converts the input exception to the target instance of class {@code target},
if the input exception is the instance of class {@code source}, throws the
converted target exception.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ExceptionHandler.java