|
|
@@ -9,6 +9,8 @@ package net.ranides.assira.trace;
|
|
|
import java.io.PrintStream;
|
|
|
import java.io.PrintWriter;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -16,7 +18,7 @@ import java.util.List;
|
|
|
*
|
|
|
* @author ranides
|
|
|
*/
|
|
|
-public class MultiException extends RuntimeException {
|
|
|
+public class MultiException extends RuntimeException implements Iterable<Throwable> {
|
|
|
|
|
|
private List<Throwable> causeList;
|
|
|
|
|
|
@@ -34,7 +36,20 @@ public class MultiException extends RuntimeException {
|
|
|
super(message);
|
|
|
this.causeList = null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Iterator<Throwable> iterator() {
|
|
|
+ if( causeList == null) {
|
|
|
+ return Collections.<Throwable>emptyList().iterator();
|
|
|
+ } else {
|
|
|
+ return causeList.iterator();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Throwable> getCauseList() {
|
|
|
+ return causeList;
|
|
|
+ }
|
|
|
+
|
|
|
public Throwable getCause(int index) {
|
|
|
if(null != causeList && index>=0 && index < causeList.size()) {
|
|
|
return causeList.get(index);
|
|
|
@@ -49,8 +64,6 @@ public class MultiException extends RuntimeException {
|
|
|
}
|
|
|
causeList.add(cause);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public void printStackTrace(PrintStream stream) {
|
|
|
@@ -86,8 +99,4 @@ public class MultiException extends RuntimeException {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|