ExceptionUtils { public static String stringifyException(final Throwable e) { if (e == null) { return STRINGIFIED_NULL_EXCEPTION; } try { StringWriter stm = new StringWriter(); PrintWriter wrt = new PrintWriter(stm); e.printStackTrace(wrt); wrt.close(); return stm.toString(); } catch (Throwable t) { return e.getClass().getName() + " (error while printing stack trace)"; } } private  ExceptionUtils(); static String stringifyException(final Throwable e); static boolean isJvmFatalError(Throwable t); static boolean isJvmFatalOrOutOfMemoryError(Throwable t); static void rethrowIfFatalError(Throwable t); static void rethrowIfFatalErrorOrOOM(Throwable t); static T firstOrSuppressed(T newException, @Nullable T previous); static void rethrow(Throwable t); static void rethrow(Throwable t, String parentMessage); static void rethrowException(Throwable t, String parentMessage); static void tryRethrowIOException(Throwable t); static void rethrowIOException(Throwable t); static Optional<Throwable> findThrowable(Throwable throwable, Class<?> searchType); static Optional<Throwable> findThrowableWithMessage(Throwable throwable, String searchMessage); static Throwable stripExecutionException(Throwable throwable); static Throwable stripCompletionException(Throwable throwable); static void tryDeserializeAndThrow(Throwable throwable, ClassLoader classLoader); static final String STRINGIFIED_NULL_EXCEPTION; }
@Test public void testStringifyNullException() { assertNotNull(ExceptionUtils.STRINGIFIED_NULL_EXCEPTION); assertEquals(ExceptionUtils.STRINGIFIED_NULL_EXCEPTION, ExceptionUtils.stringifyException(null)); }