1 22 package org.jboss.tm; 23 24 import java.io.PrintWriter ; 25 import java.io.PrintStream ; 26 import javax.transaction.xa.XAException ; 27 28 import org.jboss.util.NestedThrowable; 29 30 40 public class JBossXAException 41 extends XAException 42 implements NestedThrowable 43 { 44 45 private static final long serialVersionUID = 6614203184612359692L; 46 47 48 Throwable linked; 49 50 57 public static void rethrowAsXAException(String message, Throwable t) throws XAException 58 { 59 if (t instanceof XAException ) 60 throw (XAException ) t; 61 else 62 throw new JBossXAException(message, t); 63 } 64 65 71 public JBossXAException(final String msg) 72 { 73 super(msg); 74 } 75 76 82 public JBossXAException(final int code) 83 { 84 super(code); 85 } 86 87 94 public JBossXAException(final String msg, final Throwable linked) 95 { 96 super(msg); 97 this.linked = linked; 98 } 99 100 106 public JBossXAException(final Throwable linked) 107 { 108 this(linked.getMessage(), linked); 109 } 110 111 116 public Throwable getNested() 117 { 118 return linked; 119 } 120 121 128 public Throwable getCause() 129 { 130 return linked; 131 } 132 133 138 public String getMessage() 139 { 140 return NestedThrowable.Util.getMessage(super.getMessage(), linked); 141 } 142 143 149 public void printStackTrace(final PrintStream stream) 150 { 151 if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED) 152 super.printStackTrace(stream); 153 NestedThrowable.Util.print(linked, stream); 154 } 155 156 162 public void printStackTrace(final PrintWriter writer) 163 { 164 if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED) 165 super.printStackTrace(writer); 166 NestedThrowable.Util.print(linked, writer); 167 } 168 169 173 public void printStackTrace() 174 { 175 printStackTrace(System.err); 176 } 177 } 178 | Popular Tags |