1 16 17 package org.apache.commons.latka; 18 19 import java.io.PrintStream ; 20 import java.io.PrintWriter ; 21 22 import org.xml.sax.SAXException ; 23 24 33 public class LatkaException extends Exception { 34 35 38 protected Exception _wrappedException = null; 39 40 44 public LatkaException(String message) { 45 super(message); 46 } 47 48 53 public LatkaException(Exception e) { 54 super(e.toString()); 55 _wrappedException = e; 56 } 57 58 64 public Exception getException() { 65 return _wrappedException; 66 } 67 68 76 public static void printWrappedExceptions(LatkaException e) { 77 Exception wrappedException = e.getException(); 78 79 if (wrappedException != null) { 80 System.out.println("Wraps exception:"); 81 e.printStackTrace(); 82 83 if (wrappedException instanceof SAXException ) { 84 Exception saxWrappedException = 85 ((SAXException ) wrappedException).getException(); 86 if (saxWrappedException != null) { 87 System.out.println("Wraps exception:"); 88 e.printStackTrace(); 89 } 90 } 91 92 } 93 } 94 95 98 public void printStackTrace() { 99 if (getException() != null) { 100 System.err.println("Wrapped Exception details:"); 101 getException().printStackTrace(); 102 } 103 104 super.printStackTrace(); 105 } 106 107 111 public void printStackTrace(PrintStream s) { 112 if (getException() != null) { 113 s.println("Wrapped Exception details:"); 114 getException().printStackTrace(s); 115 } 116 117 super.printStackTrace(s); 118 } 119 120 124 public void printStackTrace(PrintWriter s) { 125 if (getException() != null) { 126 s.println("Wrapped Exception details:"); 127 getException().printStackTrace(s); 128 } 129 130 super.printStackTrace(s); 131 } 132 133 } 134 | Popular Tags |