@@ -356,10 +356,14 @@ public void assertError(Class<? extends Throwable> clazz) {
356356 throw new AssertionError ("No errors" );
357357 } else
358358 if (err .size () > 1 ) {
359- throw new AssertionError ("Multiple errors: " + err .size (), new CompositeException (err ));
359+ AssertionError ae = new AssertionError ("Multiple errors: " + err .size ());
360+ ae .initCause (new CompositeException (err ));
361+ throw ae ;
360362 } else
361363 if (!clazz .isInstance (err .get (0 ))) {
362- throw new AssertionError ("Exceptions differ; expected: " + clazz + ", actual: " + err .get (0 ), err .get (0 ));
364+ AssertionError ae = new AssertionError ("Exceptions differ; expected: " + clazz + ", actual: " + err .get (0 ));
365+ ae .initCause (err .get (0 ));
366+ throw ae ;
363367 }
364368 }
365369
@@ -378,10 +382,14 @@ public void assertError(Throwable throwable) {
378382 throw new AssertionError ("No errors" );
379383 } else
380384 if (err .size () > 1 ) {
381- throw new AssertionError ("Multiple errors: " + err .size (), new CompositeException (err ));
385+ AssertionError ae = new AssertionError ("Multiple errors: " + err .size ());
386+ ae .initCause (new CompositeException (err ));
387+ throw ae ;
382388 } else
383389 if (!throwable .equals (err .get (0 ))) {
384- throw new AssertionError ("Exceptions differ; expected: " + throwable + ", actual: " + err .get (0 ), err .get (0 ));
390+ AssertionError ae = new AssertionError ("Exceptions differ; expected: " + throwable + ", actual: " + err .get (0 ));
391+ ae .initCause (err .get (0 ));
392+ throw ae ;
385393 }
386394 }
387395
@@ -400,9 +408,13 @@ public void assertNoTerminalEvent() {
400408 throw new AssertionError ("Found " + err .size () + " errors and " + s + " completion events instead of none" );
401409 } else
402410 if (err .size () == 1 ) {
403- throw new AssertionError ("Found " + err .size () + " errors and " + s + " completion events instead of none" , err .get (0 ));
411+ AssertionError ae = new AssertionError ("Found " + err .size () + " errors and " + s + " completion events instead of none" );
412+ ae .initCause (err .get (0 ));
413+ throw ae ;
404414 } else {
405- throw new AssertionError ("Found " + err .size () + " errors and " + s + " completion events instead of none" , new CompositeException (err ));
415+ AssertionError ae = new AssertionError ("Found " + err .size () + " errors and " + s + " completion events instead of none" );
416+ ae .initCause (new CompositeException (err ));
417+ throw ae ;
406418 }
407419 }
408420 }
0 commit comments