1 45 package org.exolab.jms.service; 46 47 import java.io.PrintStream ; 48 import java.io.PrintWriter ; 49 50 51 59 public class ServiceException extends Exception { 60 61 64 private Throwable _cause; 65 66 67 70 public ServiceException() { 71 this(null, null); 72 } 73 74 79 public ServiceException(String message) { 80 this(message, null); 81 } 82 83 89 public ServiceException(Throwable cause) { 90 this(null, cause); 91 } 92 93 100 public ServiceException(String message, Throwable cause) { 101 super(message); 102 _cause = cause; 103 } 104 105 111 public Throwable getRootCause() { 112 return _cause; 113 } 114 115 119 public void printStackTrace() { 120 printStackTrace(System.err); 121 } 122 123 127 public void printStackTrace(PrintStream stream) { 128 synchronized (stream) { 129 if (_cause != null) { 130 stream.print(getClass().getName() + ": "); 131 _cause.printStackTrace(stream); 132 } else { 133 super.printStackTrace(stream); 134 } 135 } 136 } 137 138 142 public void printStackTrace(PrintWriter writer) { 143 synchronized (writer) { 144 if (_cause != null) { 145 writer.print(getClass().getName() + ": "); 146 _cause.printStackTrace(writer); 147 } else { 148 super.printStackTrace(writer); 149 } 150 } 151 } 152 153 } 154 | Popular Tags |