Exceptions { public static String traceText(Throwable exception) { requireNonNull(exception, "exception"); final StackTraceWriter writer = new StackTraceWriter(); exception.printStackTrace(writer); return writer.toString(); } 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 testTraceText() { final String trace = Exceptions.traceText(new Exception("foo")); assertThat(trace).startsWith(Exception.class.getName() + ": foo\n" + "\tat " + ExceptionsTest.class.getName()); }