@Test public void testDetachMultistatusFromCoreException() { // #input // st4 // -ex4 // --cex // ---mst3 // ----ex1 // ----st1 // -----ex2 // ----st2 // -----ex3 Status st = st(ex(cex(mst(ex(), st(ex()), st(ex()))))); // #expected output // st4 // -ex4 // --cex(mst3) // ---ex1 // -mst3 (moved from cex to st4.children) // --ex1 // --st1 // ---ex2 // --st2 // ---ex3 org.eclipse.epp.internal.logging.aeri.ui.model.Status st4 = Reports.newStatus(st, configuration); Throwable ex4 = st4.getException(); Throwable cex = ex4.getCause(); Throwable ex1 = cex.getCause(); org.eclipse.epp.internal.logging.aeri.ui.model.Status mst3 = st4.getChildren().get(0); Throwable ex1b = mst3.getException(); org.eclipse.epp.internal.logging.aeri.ui.model.Status st1 = mst3.getChildren().get(0); Throwable ex2 = st1.getException(); org.eclipse.epp.internal.logging.aeri.ui.model.Status st2 = mst3.getChildren().get(1); Throwable ex3 = st2.getException(); assertThat(st4.getMessage(), is("st4")); assertThat(ex4.getMessage(), is("ex4")); assertThat(cex.getMessage(), is("mst3")); assertThat(ex1.getMessage(), is("ex1")); assertThat( mst3.getMessage(), is("mst3 [detached from CoreException of Status 'st4' by Error Reporting]")); assertThat(ex1b.getMessage(), is("ex1")); assertThat(st1.getMessage(), is("st1")); assertThat(ex2.getMessage(), is("ex2")); assertThat(st2.getMessage(), is("st2")); assertThat(ex3.getMessage(), is("ex3")); }
private void extractCauses(Throwable failure, List<Throwable> causes) { if (failure instanceof MultipleBuildFailures) { MultipleBuildFailures exception = (MultipleBuildFailures) failure; for (Throwable componentFailure : exception.getCauses()) { extractCauses(componentFailure, causes); } } else if (failure instanceof LocationAwareException) { causes.addAll(((LocationAwareException) failure).getReportableCauses()); } else { causes.add(failure.getCause()); } }