1 23 package org.mdarad.framework.exception; 24 25 import java.io.PrintStream ; 26 import java.io.PrintWriter ; 27 import java.util.Iterator ; 28 import java.util.Vector ; 29 30 public class ChainedException extends SystemException { 31 Vector exceptions = new Vector (); 32 33 public ChainedException() { 34 super(); 35 } 36 37 public ChainedException(String message) { 38 super(message); 39 } 40 41 public ChainedException(Throwable cause) { 42 super(cause); 43 } 44 45 public ChainedException(String message, Throwable cause) { 46 super(message, cause); 47 } 48 49 public void chain(Throwable cause) { 50 chain(null, cause); 51 } 52 53 public void chain(String message, Throwable cause) { 54 if (message == null) 55 exceptions.add(new SystemException(message, cause)); 56 } 57 58 public void printStackTrace() { 59 Iterator iterator = exceptions.iterator(); 60 61 while (iterator.hasNext()) { 62 Throwable throwable = (Throwable ) iterator.next(); 63 throwable.printStackTrace(); 64 } 65 } 66 67 public void printStackTrace(PrintWriter s) { 68 Iterator iterator = exceptions.iterator(); 69 70 while (iterator.hasNext()) { 71 Throwable throwable = (Throwable ) iterator.next(); 72 throwable.printStackTrace(s); 73 } 74 } 75 76 public void printStackTrace(PrintStream s) { 77 Iterator iterator = exceptions.iterator(); 78 79 while (iterator.hasNext()) { 80 Throwable throwable = (Throwable ) iterator.next(); 81 throwable.printStackTrace(s); 82 } 83 } 84 85 public Throwable getThrowable(int index) { 86 return (Throwable ) exceptions.get(index); 87 } 88 } 89 | Popular Tags |