1 28 29 package com.caucho.ejb; 30 31 import com.caucho.amber.AmberObjectNotFoundException; 32 import com.caucho.util.ExceptionWrapper; 33 34 import javax.ejb.FinderException ; 35 import javax.ejb.ObjectNotFoundException ; 36 import java.util.logging.Level ; 37 import java.util.logging.Logger ; 38 39 42 public class FinderExceptionWrapper extends javax.ejb.FinderException 43 implements ExceptionWrapper { 44 private static final Logger log 45 = Logger.getLogger(FinderExceptionWrapper.class.getName()); 46 47 50 public FinderExceptionWrapper() 51 { 52 } 53 58 public FinderExceptionWrapper(String msg) 59 { 60 super(msg); 61 } 62 63 68 public FinderExceptionWrapper(Throwable rootCause) 69 { 70 super(rootCause.toString()); 71 72 initCause(rootCause); 73 } 74 75 78 public static FinderException create(Throwable rootCause) 79 { 80 while (rootCause instanceof ExceptionWrapper) { 81 ExceptionWrapper wrapper = (ExceptionWrapper) rootCause; 82 83 if (wrapper.getRootCause() != null) 84 rootCause = wrapper.getRootCause(); 85 else 86 break; 87 } 88 89 if (rootCause instanceof FinderException ) 90 return (FinderException ) rootCause; 91 else if (rootCause instanceof AmberObjectNotFoundException) { 92 log.log(Level.FINER, rootCause.toString(), rootCause); 93 94 return new ObjectNotFoundException(rootCause.getMessage()); 95 } 96 else 97 return new FinderExceptionWrapper(rootCause); 98 } 99 100 105 public Throwable getRootCause() 106 { 107 return getCause(); 108 } 109 } 110 111 | Popular Tags |