1 2 24 package org.enhydra.tool.common; 25 import java.io.*; 27 import java.util.ResourceBundle ; 28 public class ToolException extends Exception { 30 31 static ResourceBundle res = 32 ResourceBundle.getBundle("org.enhydra.tool.common.Res"); 34 private Throwable parent = null; 36 private final boolean debug = false; 37 38 44 public ToolException(String message) { 45 super(message); 46 } 47 48 56 public ToolException(Throwable chain, String message) { 57 super(message); 58 parent = chain; 59 if (debug) { 60 System.err.println("-----------------------"); 61 parent.printStackTrace(System.err); 62 System.err.println("-----------------------"); 63 } 64 } 65 66 73 public String getMessage() { 74 StringBuffer buf = new StringBuffer (); 75 76 buf.append(ResUtil.format(res.getString("Tool_Exception_n_0_"), 77 super.getMessage())); 78 if (parent != null) { 79 buf.append('\n'); 80 buf.append(" " + parent.getMessage()); } 82 return buf.toString(); 83 } 84 85 89 public void printStackTrace() { 90 super.printStackTrace(); 91 if (parent != null) { 92 parent.printStackTrace(); 93 } 94 } 95 96 public void printStackTrace(PrintStream stream) { 97 super.printStackTrace(stream); 98 if (parent != null) { 99 parent.printStackTrace(stream); 100 } 101 } 102 103 104 } 105 | Popular Tags |