1 28 29 package com.caucho.ejb.burlap; 30 31 import com.caucho.util.ExceptionWrapper; 32 33 import java.io.PrintStream ; 34 import java.io.PrintWriter ; 35 import java.rmi.RemoteException ; 36 37 40 public class BurlapProtocolException extends java.rmi.RemoteException 41 implements ExceptionWrapper { 42 private Throwable rootCause; 43 44 47 public BurlapProtocolException() 48 { 49 } 50 55 public BurlapProtocolException(String msg) 56 { 57 super(msg); 58 } 59 60 65 public BurlapProtocolException(Throwable rootCause) 66 { 67 super(rootCause.getMessage()); 68 69 this.rootCause = rootCause; 70 } 71 72 75 public static BurlapProtocolException create(Throwable rootCause) 76 { 77 if (rootCause instanceof BurlapProtocolException) 78 return ((BurlapProtocolException) rootCause); 79 else 80 return new BurlapProtocolException(rootCause); 81 } 82 83 86 public static RemoteException createRemote(Throwable rootCause) 87 { 88 if (rootCause instanceof RemoteException ) 89 return ((RemoteException ) rootCause); 90 else 91 return new BurlapProtocolException(rootCause); 92 } 93 94 99 public Throwable getRootCause() 100 { 101 return rootCause; 102 } 103 104 107 public String getMessage() 108 { 109 if (rootCause != null) 110 return rootCause.getMessage(); 111 else 112 return super.getMessage(); 113 } 114 115 118 public void printStackTrace() 119 { 120 if (rootCause != null) 121 rootCause.printStackTrace(); 122 else 123 super.printStackTrace(); 124 } 125 126 129 public void printStackTrace(PrintStream os) 130 { 131 if (rootCause != null) 132 rootCause.printStackTrace(os); 133 else 134 super.printStackTrace(os); 135 } 136 137 140 public void printStackTrace(PrintWriter os) 141 { 142 if (rootCause != null) 143 rootCause.printStackTrace(os); 144 else 145 super.printStackTrace(os); 146 } 147 148 151 public String toString() 152 { 153 if (rootCause == null) 154 return super.toString(); 155 else 156 return getClass().getName() + ": " + rootCause; 157 } 158 } 159 160 | Popular Tags |