public static IOException rethrow(Throwable error) throws IOException {
    if (error instanceof IOException) {
      setStackTrace(error);
      throw (IOException) error;
    } else if (error instanceof RuntimeException) {
      setStackTrace(error);
      throw (RuntimeException) error;
    } else if (error instanceof Error) {
      setStackTrace(error);
      throw (Error) error;
    } else {
      throw new IOException(error);
    }
  }
If we could propagate the given {@code error} directly, we will fill the stack trace with the
current thread's stack trace so it is easier to trace where is the exception thrown. If not, we
will just create a new IOException and then throw it.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/FutureUtils.java