1 19 20 23 24 package org.netbeans.modules.schema2beans; 25 26 import java.util.*; 27 import java.io.*; 28 29 public class Schema2BeansNestedException extends Schema2BeansException implements Serializable { 30 protected Throwable childThrowable; 31 protected String message; 32 protected String stackTrace; 33 34 public Schema2BeansNestedException(Throwable e) { 35 super(""); 36 if (DDLogFlags.debug) { 37 System.out.println("Created Schema2BeansNestedException1: e="+e); 38 e.printStackTrace(); 39 } 40 childThrowable = e; 41 message = childThrowable.getMessage(); 42 genStackTrace(); 43 } 44 45 public Schema2BeansNestedException(String mesg, Throwable e) { 46 super(mesg); 47 if (DDLogFlags.debug) { 48 System.out.println("Created Schema2BeansNestedException2: e="+e+" mesg="+mesg); 49 e.printStackTrace(); 50 } 51 childThrowable = e; 52 message = mesg+"\n"+childThrowable.getMessage(); 53 genStackTrace(); 54 } 55 56 public Throwable getCause() { 57 return childThrowable; 58 } 59 60 public String getMessage() { 61 return message; 62 } 63 64 protected void genStackTrace() { 65 StringWriter strWriter = new StringWriter(); 66 PrintWriter s = new PrintWriter(strWriter); 67 if (childThrowable == null) { 68 super.printStackTrace(s); 69 } else { 70 s.println(super.getMessage()); 71 childThrowable.printStackTrace(s); 72 } 73 stackTrace = strWriter.toString(); 74 } 75 76 public void printStackTrace(PrintStream s) { 77 s.println(stackTrace); 78 } 79 80 public void printStackTrace(PrintWriter s) { 81 s.println(stackTrace); 82 } 83 84 public void printStackTrace() { 85 System.err.println(stackTrace); 86 } 87 } 88 | Popular Tags |