/** * Collects suppressed exceptions from throwable and all it causes. * * @param t Throwable. * @return List of suppressed throwables. */ public static List<Throwable> getSuppressedList(@Nullable Throwable t) { List<Throwable> result = new ArrayList<>(); if (t == null) return result; do { for (Throwable suppressed : t.getSuppressed()) { result.add(suppressed); result.addAll(getSuppressedList(suppressed)); } } while ((t = t.getCause()) != null); return result; }
/** * Wrap throwable by presented on Visor throwable object. * * @param cause Base throwable object. */ public VisorExceptionWrapper(Throwable cause) { assert cause != null; clsSimpleName = cause.getClass().getSimpleName(); clsName = cause.getClass().getName(); detailMsg = cause.getMessage(); StackTraceElement[] stackTrace = cause.getStackTrace(); if (stackTrace != null) setStackTrace(stackTrace); if (cause.getCause() != null) initCause(new VisorExceptionWrapper(cause.getCause())); List<Throwable> suppressed = X.getSuppressedList(cause); for (Throwable sup : suppressed) addSuppressed(new VisorExceptionWrapper(sup)); }
/** * @throws Exception If failed. */ @Test public void testXGetSuppressedList() throws Exception { IgniteCheckedException me = prepareMultiException(); assertEquals(3, X.getSuppressedList(me).size()); RuntimeException e = new RuntimeException(); e.addSuppressed(me); List<Throwable> suppresseds = X.getSuppressedList(e); assertEquals(4, suppresseds.size()); assertEquals("Test message.", suppresseds.get(0).getMessage()); for (int i = 1; i <= 3; i++) assertEquals("Demo exception.", suppresseds.get(1).getMessage()); }
for (Throwable t : X.getSuppressedList(e)) sb.a(t.getMessage()).a("\n");
"rmtNode=" + node + ", errs=" + errs + ", connectErrs=" + X.getSuppressedList(errs) + ']');
/** * Collects suppressed exceptions from throwable and all it causes. * * @param t Throwable. * @return List of suppressed throwables. */ public static List<Throwable> getSuppressedList(@Nullable Throwable t) { List<Throwable> result = new ArrayList<>(); if (t == null) return result; do { for (Throwable suppressed : t.getSuppressed()) { result.add(suppressed); result.addAll(getSuppressedList(suppressed)); } } while ((t = t.getCause()) != null); return result; }
/** * Wrap throwable by presented on Visor throwable object. * * @param cause Base throwable object. */ public VisorExceptionWrapper(Throwable cause) { assert cause != null; clsSimpleName = cause.getClass().getSimpleName(); clsName = cause.getClass().getName(); detailMsg = cause.getMessage(); StackTraceElement[] stackTrace = cause.getStackTrace(); if (stackTrace != null) setStackTrace(stackTrace); if (cause.getCause() != null) initCause(new VisorExceptionWrapper(cause.getCause())); List<Throwable> suppressed = X.getSuppressedList(cause); for (Throwable sup : suppressed) addSuppressed(new VisorExceptionWrapper(sup)); }
for (Throwable t : X.getSuppressedList(e)) sb.a(t.getMessage()).a("\n");
"rmtNode=" + node + ", errs=" + errs + ", connectErrs=" + X.getSuppressedList(errs) + ']');