### Question:
RemoteExceptionUtil { public static void throwOriginalExceptionIfPossible(final Error error) { Throwable throwable = toThrowable(error); if (throwable instanceof RuntimeException) throw (RuntimeException) throwable; if (throwable instanceof java.lang.Error) throw (java.lang.Error) throwable; throw new RuntimeException(throwable); } private  RemoteExceptionUtil(); static void throwOriginalExceptionIfPossible(final Error error);  }### Answer:
@Test public void simpleIllegalArgumentException() { IllegalArgumentException origEx = new IllegalArgumentException("bla > 0"); Error error = new Error(origEx); try { RemoteExceptionUtil.throwOriginalExceptionIfPossible(error); } catch (Exception newEx) { newEx.printStackTrace(); assertThat(newEx).isInstanceOf(origEx.getClass()); assertThat(newEx.getMessage()).isEqualTo("bla > 0"); } }
@Test public void nestedSQLException() { SQLException origNestedEx = createSQLException("blablubbxxx"); RuntimeException origEx = createRuntimeException(origNestedEx); assertThat(origEx.getMessage()).isEqualTo("java.sql.SQLException: blablubbxxx"); Error error = new Error(origEx); try { RemoteExceptionUtil.throwOriginalExceptionIfPossible(error); } catch (Exception newEx) { newEx.printStackTrace(); assertThat(newEx).isInstanceOf(RuntimeException.class); assertThat(newEx.getMessage()).isEqualTo("java.sql.SQLException: blablubbxxx"); assertThat(newEx.getCause()).isNotNull(); assertThat(newEx.getCause()).isInstanceOf(SQLException.class); assertThat(newEx.getCause().getMessage()).isEqualTo("blablubbxxx"); } }