1 19 20 32 33 package org.netbeans.modules.schema2beans; 34 35 import java.util.*; 36 import java.io.*; 37 38 public class Schema2BeansRuntimeException extends RuntimeException implements Serializable { 39 protected Throwable childThrowable; 40 protected String message; 41 protected String stackTrace; 42 43 public Schema2BeansRuntimeException(Throwable e) { 44 super(""); 45 childThrowable = e; 48 message = childThrowable.getMessage(); 49 genStackTrace(); 50 } 51 52 public Schema2BeansRuntimeException(String mesg) { 53 super(mesg); 54 childThrowable = null; 56 message = mesg; 57 genStackTrace(); 58 } 59 60 public Schema2BeansRuntimeException(String mesg, Throwable e) { 61 super(mesg); 62 childThrowable = e; 65 message = mesg+"\n"+childThrowable.getMessage(); 66 genStackTrace(); 67 } 68 69 public Throwable getCause() { 70 return childThrowable; 71 } 72 73 public String getMessage() { 74 return message; 75 } 76 77 protected void genStackTrace() { 78 StringWriter strWriter = new StringWriter(); 79 PrintWriter s = new PrintWriter(strWriter); 80 if (childThrowable == null) { 81 super.printStackTrace(s); 82 } else { 83 s.println(super.getMessage()); 84 childThrowable.printStackTrace(s); 85 } 86 stackTrace = strWriter.toString(); 87 } 88 89 public void printStackTrace(PrintStream s) { 90 s.println(stackTrace); 91 } 92 93 public void printStackTrace(PrintWriter s) { 94 s.println(stackTrace); 95 } 96 97 public void printStackTrace() { 98 System.out.println(stackTrace); 99 } 100 } 101 | Popular Tags |