1 15 16 package javassist; 17 18 import javassist.compiler.CompileError; 19 20 23 public class CannotCompileException extends Exception { 24 private String message; 25 private Throwable cause; 26 27 public String getReason() { 28 if (message != null) 29 return message; 30 else 31 return this.toString(); 32 } 33 34 39 public CannotCompileException(String msg) { 40 super(msg); 41 message = msg; 42 cause = null; 43 } 44 45 51 public CannotCompileException(Throwable e) { 52 super("by " + e.toString()); 53 message = null; 54 cause = e; 55 } 56 57 64 public CannotCompileException(String msg, Throwable e) { 65 this(msg); 66 cause = e; 67 } 68 69 73 public CannotCompileException(NotFoundException e) { 74 this("cannot find " + e.getMessage(), e); 75 } 76 77 80 public CannotCompileException(CompileError e) { 81 this("[source error] " + e.getMessage(), e); 82 } 83 84 88 public CannotCompileException(ClassNotFoundException e, String name) { 89 this("cannot find " + name, e); 90 } 91 92 95 public CannotCompileException(ClassFormatError e, String name) { 96 this("invalid class format: " + name, e); 97 } 98 99 102 public void printStackTrace(java.io.PrintWriter w) { 103 super.printStackTrace(w); 104 if (cause != null) { 105 w.println("Caused by:"); 106 cause.printStackTrace(w); 107 } 108 } 109 } 110 | Popular Tags |