1 28 29 package com.caucho.ejb; 30 31 import com.caucho.util.ExceptionWrapper; 32 33 import javax.ejb.RemoveException ; 34 35 38 public class RemoveExceptionWrapper extends javax.ejb.RemoveException 39 implements ExceptionWrapper { 40 private Throwable rootCause; 41 42 45 public RemoveExceptionWrapper() 46 { 47 } 48 53 public RemoveExceptionWrapper(String msg) 54 { 55 super(msg); 56 } 57 58 63 public RemoveExceptionWrapper(Throwable rootCause) 64 { 65 super(rootCause.getMessage()); 66 67 this.rootCause = rootCause; 68 } 69 70 73 public static RemoveException create(Throwable rootCause) 74 { 75 while (rootCause instanceof ExceptionWrapper) { 76 ExceptionWrapper wrapper = (ExceptionWrapper) rootCause; 77 78 if (wrapper.getRootCause() != null) 79 rootCause = wrapper.getRootCause(); 80 else 81 break; 82 } 83 84 if (rootCause instanceof RemoveException ) 85 return (RemoveException ) rootCause; 86 else 87 return new RemoveExceptionWrapper(rootCause); 88 } 89 90 95 public Throwable getRootCause() 96 { 97 return rootCause; 98 } 99 100 103 public String getMessage() 104 { 105 if (rootCause != null) 106 return rootCause.getMessage(); 107 else 108 return super.getMessage(); 109 } 110 111 114 public String toString() 115 { 116 if (rootCause == null) 117 return super.toString(); 118 else 119 return getClass().getName() + ": " + rootCause; 120 } 121 } 122 123 | Popular Tags |