Exceptions { public static Throwable peel(Throwable throwable) { requireNonNull(throwable, "throwable"); Throwable cause = throwable.getCause(); while (cause != null && cause != throwable && (throwable instanceof CompletionException || throwable instanceof ExecutionException || throwable instanceof InvocationTargetException || throwable instanceof ExceptionInInitializerError)) { throwable = cause; cause = throwable.getCause(); } return throwable; } private  Exceptions(); static void logIfUnexpected(Logger logger, Channel ch, Throwable cause); static void logIfUnexpected(Logger logger, Channel ch, String debugData, Throwable cause); static void logIfUnexpected(Logger logger, Channel ch,
                                       @Nullable SessionProtocol protocol, Throwable cause); static void logIfUnexpected(Logger logger, Channel ch, @Nullable SessionProtocol protocol,
                                       String debugData, Throwable cause); static boolean isExpected(Throwable cause); static boolean isStreamCancelling(Throwable cause); static T clearTrace(T exception); @SuppressWarnings("ReturnOfNull") static T throwUnsafely(Throwable cause); static void throwIfFatal(Throwable t); static Throwable peel(Throwable throwable); static String traceText(Throwable exception);  }
@Test public void testPeel() { final IllegalArgumentException originalException = new IllegalArgumentException(); assertThat(Exceptions.peel(originalException)).isSameAs(originalException); final CompletionException completionException = new CompletionException(originalException); assertThat(Exceptions.peel(completionException)).isSameAs(originalException); final CompletionException wrappedTwice = new CompletionException(completionException); assertThat(Exceptions.peel(wrappedTwice)).isSameAs(originalException); final ExecutionException executionException = new ExecutionException(completionException); assertThat(Exceptions.peel(executionException)).isSameAs(originalException); final InvocationTargetException invocationTargetException = new InvocationTargetException( executionException); assertThat(Exceptions.peel(invocationTargetException)).isSameAs(originalException); final ExceptionInInitializerError exceptionInInitializerError = new ExceptionInInitializerError( executionException); assertThat(Exceptions.peel(exceptionInInitializerError)).isSameAs(originalException); }