1 18 package org.apache.tools.ant; 19 20 import java.io.PrintStream ; 21 import java.io.PrintWriter ; 22 23 26 public class BuildException extends RuntimeException { 27 28 29 private Throwable cause; 30 31 32 private Location location = Location.UNKNOWN_LOCATION; 33 34 37 public BuildException() { 38 super(); 39 } 40 41 47 public BuildException(String message) { 48 super(message); 49 } 50 51 60 public BuildException(String message, Throwable cause) { 61 super(message); 62 this.cause = cause; 63 } 64 65 76 public BuildException(String msg, Throwable cause, Location location) { 77 this(msg, cause); 78 this.location = location; 79 } 80 81 87 public BuildException(Throwable cause) { 88 super(cause.toString()); 89 this.cause = cause; 90 } 91 92 101 public BuildException(String message, Location location) { 102 super(message); 103 this.location = location; 104 } 105 106 115 public BuildException(Throwable cause, Location location) { 116 this(cause); 117 this.location = location; 118 } 119 120 126 public Throwable getException() { 127 return cause; 128 } 129 130 136 public Throwable getCause() { 137 return getException(); 138 } 139 140 145 public String toString() { 146 return location.toString() + getMessage(); 147 } 148 149 155 public void setLocation(Location location) { 156 this.location = location; 157 } 158 159 164 public Location getLocation() { 165 return location; 166 } 167 168 172 public void printStackTrace() { 173 printStackTrace(System.err); 174 } 175 176 183 public void printStackTrace(PrintStream ps) { 184 synchronized (ps) { 185 super.printStackTrace(ps); 186 if (cause != null) { 187 ps.println("--- Nested Exception ---"); 188 cause.printStackTrace(ps); 189 } 190 } 191 } 192 193 200 public void printStackTrace(PrintWriter pw) { 201 synchronized (pw) { 202 super.printStackTrace(pw); 203 if (cause != null) { 204 pw.println("--- Nested Exception ---"); 205 cause.printStackTrace(pw); 206 } 207 } 208 } 209 } 210 | Popular Tags |