1 30 31 package com.caucho.ejb; 32 33 import com.caucho.util.ExceptionWrapper; 34 35 import java.io.PrintStream ; 36 import java.io.PrintWriter ; 37 38 41 public class RemoteExceptionWrapper extends java.rmi.RemoteException 42 implements ExceptionWrapper { 43 private Throwable rootCause; 44 45 48 public RemoteExceptionWrapper() 49 { 50 } 51 56 public RemoteExceptionWrapper(String msg) 57 { 58 super(msg); 59 } 60 61 66 public RemoteExceptionWrapper(Throwable rootCause) 67 { 68 super(rootCause.getMessage()); 69 70 this.rootCause = rootCause; 71 } 72 73 public static RemoteExceptionWrapper create(Throwable rootCause) 74 { 75 if (rootCause instanceof RemoteExceptionWrapper) 76 return (RemoteExceptionWrapper) rootCause; 77 else 78 return new RemoteExceptionWrapper(rootCause); 79 } 80 81 86 public Throwable getRootCause() 87 { 88 return rootCause; 89 } 90 91 94 public String getMessage() 95 { 96 if (rootCause != null) 97 return rootCause.getMessage(); 98 else 99 return super.getMessage(); 100 } 101 102 105 public void printStackTrace() 106 { 107 if (rootCause != null) 108 rootCause.printStackTrace(); 109 else 110 super.printStackTrace(); 111 } 112 113 116 public void printStackTrace(PrintStream os) 117 { 118 if (rootCause != null) 119 rootCause.printStackTrace(os); 120 else 121 super.printStackTrace(os); 122 } 123 124 127 public void printStackTrace(PrintWriter os) 128 { 129 if (rootCause != null) 130 rootCause.printStackTrace(os); 131 else 132 super.printStackTrace(os); 133 } 134 135 138 public String toString() 139 { 140 if (rootCause == null) 141 return super.toString(); 142 else 143 return getClass().getName() + ": " + rootCause; 144 } 145 } 146 147 | Popular Tags |