/** * Create a MultiException which may be thrown. * * @param nested The nested exceptions which will be suppressed by this * exception. */ private MultiException(List<Throwable> nested) { super(DEFAULT_MESSAGE); this.nested = new ArrayList<>(nested); if (nested.size() > 0) initCause(nested.get(0)); for (Throwable t : nested) { if (t != this) addSuppressed(t); } }
/** * Create a MultiException which may be thrown. * * @param nested The nested exceptions which will be suppressed by this * exception. */ private MultiException(List<Throwable> nested) { super(DEFAULT_MESSAGE); this.nested = new ArrayList<>(nested); if (nested.size() > 0) initCause(nested.get(0)); for (Throwable t : nested) { if (t != this) addSuppressed(t); } }
public void add(Throwable e) { if (e==null) throw new IllegalArgumentException(); if(nested == null) { initCause(e); nested = new ArrayList<>(); } else addSuppressed(e); if (e instanceof MultiException) { MultiException me = (MultiException)e; nested.addAll(me.nested); } else nested.add(e); }