@Test
  public void testWrapConnectionException() throws Exception {
    List<Throwable> exceptions = new ArrayList<>();
    for (Class<? extends Throwable> clazz : ClientExceptionsUtil.getConnectionExceptionTypes()) {
      exceptions.add(create(clazz));
    }
    Address addr = Address.fromParts("127.0.0.1", 12345);
    for (Throwable exception : exceptions) {
      if (exception instanceof TimeoutException) {
        assertThat(IPCUtil.wrapException(addr, null, exception),
          instanceOf(TimeoutIOException.class));
      } else {
        IOException ioe =
          IPCUtil.wrapException(addr, RegionInfoBuilder.FIRST_META_REGIONINFO, exception);
        // Assert that the exception contains the Region name if supplied. HBASE-25735.
        // Not all exceptions get the region stuffed into it.
        if (ioe.getMessage() != null) {
          assertTrue(ioe.getMessage()
            .contains(RegionInfoBuilder.FIRST_META_REGIONINFO.getRegionNameAsString()));
        }
        assertThat(ioe, instanceOf(exception.getClass()));
      }
    }
  }
See HBASE-21862, it is important to keep original exception type for connection exceptions.
hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestIPCUtil.java