Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 27 package org.htmlparser.util; 28 29 58 59 import java.io.PrintStream ; 60 import java.io.PrintWriter ; 61 import java.util.Vector ; 62 63 public class ChainedException 64 extends Exception  65 { 66 protected Throwable throwable; 67 68 public ChainedException() {} 69 70 public ChainedException(String message) 71 { 72 super(message); 73 } 74 75 public ChainedException(Throwable throwable) 76 { 77 this.throwable = throwable; 78 } 79 80 public ChainedException(String message, Throwable throwable) 81 { 82 super(message); 83 this.throwable = throwable; 84 } 85 86 public String [] getMessageChain() 87 { 88 Vector list = getMessageList(); 89 String [] chain = new String [list.size()]; 90 list.copyInto (chain); 91 return chain; 92 } 93 94 public Vector getMessageList() 95 { 96 Vector list = new Vector (); 97 list.addElement(getMessage()); 98 if (throwable != null) 99 { 100 if (throwable instanceof ChainedException) 101 { 102 ChainedException chain = (ChainedException)throwable; 103 Vector sublist = chain.getMessageList (); 104 for (int i = 0; i < sublist.size (); i++) 105 list.addElement (sublist.elementAt (i)); 106 } 107 else 108 { 109 String message = throwable.getMessage(); 110 if (message != null && !message.equals("")) 111 { 112 list.addElement (message); 113 } 114 } 115 } 116 return list; 117 } 118 119 public Throwable getThrowable() 120 { 121 return throwable; 122 } 123 124 public void printStackTrace() 125 { 126 printStackTrace(System.err); 127 } 128 129 public void printStackTrace(PrintStream out) 130 { 131 synchronized (out) 132 { 133 if (throwable != null) 134 { 135 out.println(getClass().getName() + 136 ": " + getMessage() + ";"); 137 throwable.printStackTrace(out); 138 } 139 else 140 { 141 super.printStackTrace(out); 142 } 143 } 144 } 145 146 public void printStackTrace(PrintWriter out) 147 { 148 synchronized (out) 149 { 150 if (throwable != null) 151 { 152 out.println(getClass().getName() + 153 ": " + getMessage() + ";"); 154 throwable.printStackTrace(out); 155 } 156 else 157 { 158 super.printStackTrace(out); 159 } 160 } 161 } 162 } 163 164
| Popular Tags
|