473266 - init MultiException cause

This commit is contained in:
Greg Wilkins 2015-07-23 09:02:52 +10:00
parent 7bf6cec74e
commit 3244088565
2 changed files with 16 additions and 0 deletions

View File

@ -47,7 +47,10 @@ public class MultiException extends Exception
throw new IllegalArgumentException();
if(nested == null)
{
initCause(e);
nested = new ArrayList<>();
}
if (e instanceof MultiException)
{

View File

@ -148,4 +148,17 @@ public class MultiExceptionTest
assertTrue(e.getCause()==me);
}
}
@Test
public void testCause() throws Exception
{
MultiException me = new MultiException();
IOException io = new IOException("one");
RuntimeException run = new RuntimeException("two");
me.add(io);
me.add(run);
assertEquals(2,me.size());
assertEquals(io,me.getCause());
}
}