001 package org.nanocontainer.persistence;
002
003
004 /**
005 * Default factory for the persistence exceptions
006 *
007 * @version $Revision: $
008 */
009 public class DefaultExceptionFactory implements ExceptionFactory {
010
011 public RuntimeException createPersistenceException(Throwable cause) {
012 if (cause instanceof PersistenceException) {
013 return (PersistenceException) cause;
014 }
015
016 return new PersistenceException(cause);
017 }
018
019 public RuntimeException createConcurrencyFailureException(Throwable cause) {
020 return new ConcurrencyFailureException(cause);
021 }
022
023 public RuntimeException createStaleObjectStateException(Throwable cause, String type, Object id) {
024 return new StaleObjectStateException(cause, type, id);
025 }
026
027 public RuntimeException createObjectRetrievalFailureException(Throwable cause, String type, Object id) {
028 return new ObjectRetrievalFailureException(cause, type, id);
029 }
030
031 public RuntimeException createTransactionException(Throwable cause) {
032 return new TransactionException(cause);
033 }
034 }