1 23 package org.enhydra.kelp.common.codegen; 24 25 import org.enhydra.kelp.common.Constants; 27 import java.io.PrintStream ; 29 30 34 public class CodeGenException extends Exception { 35 private Throwable parent = null; 36 private boolean decoy = false; 37 38 44 public CodeGenException(String message) { 45 super(message); 46 } 47 48 56 public CodeGenException(Throwable hidden) { 57 super(new String ()); 58 parent = hidden.fillInStackTrace(); 59 decoy = true; 60 } 61 62 71 public CodeGenException(Throwable chain, String message) { 72 super(message); 73 parent = chain.fillInStackTrace(); 74 } 75 76 84 public String getMessage() { 85 StringBuffer buf = new StringBuffer (); 86 87 if ((!decoy) || (parent == null)) { 88 buf.append(super.getMessage()); 89 } 90 if (parent != null) { 91 buf.append('\n'); 92 buf.append(Constants.TAB4); 93 buf.append(parent.getMessage()); 94 } 95 return buf.toString(); 96 } 97 98 public void printStackTrace() { 99 super.printStackTrace(); 100 if (parent != null) { 101 parent.printStackTrace(); 102 } 103 } 104 105 public void printStackTrace(PrintStream stream) { 106 super.printStackTrace(stream); 107 if (parent != null) { 108 parent.printStackTrace(stream); 109 } 110 } 111 112 113 114 } 115 | Popular Tags |