{
if (jpe.getNestedExceptions() != null)
{
if (jpe.getFailedObject() != null)
{
return new JDODataStoreException(jpe.getMessage(), jpe.getNestedExceptions(), jpe.getFailedObject());
}
return new JDODataStoreException(jpe.getMessage(), jpe.getNestedExceptions());
}
else if (jpe.getFailedObject() != null)
{
NucleusLogger.JDO.info("Exception thrown", jpe);
return new JDODataStoreException(jpe.getMessage(), jpe.getFailedObject());
}
else
{
NucleusLogger.JDO.info("Exception thrown", jpe);
return new JDODataStoreException(jpe.getMessage(), jpe);
}
}
}
else if (jpe instanceof NucleusObjectNotFoundException)
{
//sadly JDOObjectNotFoundException dont allow nested exceptions and failed objects together
if (jpe.getFailedObject() != null)
{
return new JDOObjectNotFoundException(jpe.getMessage(), jpe.getFailedObject());
}
else if (jpe.getNestedExceptions() != null)
{
return new JDOObjectNotFoundException(jpe.getMessage(), jpe.getNestedExceptions());
}
else
{
return new JDOObjectNotFoundException(jpe.getMessage(), new Throwable[]{jpe});
}
}
else if (jpe instanceof NucleusUserException)
{
if (jpe.isFatal())
{
if (jpe.getNestedExceptions() != null)
{
if (jpe.getFailedObject() != null)
{
return new JDOFatalUserException(jpe.getMessage(), jpe.getNestedExceptions(), jpe.getFailedObject());
}
return new JDOFatalUserException(jpe.getMessage(), jpe.getNestedExceptions());
}
else if (jpe.getFailedObject() != null)
{
NucleusLogger.JDO.info("Exception thrown", jpe);
return new JDOFatalUserException(jpe.getMessage(), jpe.getFailedObject());
}
else
{
NucleusLogger.JDO.info("Exception thrown", jpe);
return new JDOFatalUserException(jpe.getMessage(), jpe);
}
}
else
{
if (jpe.getNestedExceptions() != null)
{
if (jpe.getFailedObject() != null)
{
return new JDOUserException(jpe.getMessage(), jpe.getNestedExceptions(), jpe.getFailedObject());
}
return new JDOUserException(jpe.getMessage(), jpe.getNestedExceptions());
}
else if (jpe.getFailedObject() != null)
{
NucleusLogger.JDO.info("Exception thrown", jpe);
return new JDOUserException(jpe.getMessage(), jpe.getFailedObject());
}
else
{
NucleusLogger.JDO.info("Exception thrown", jpe);
return new JDOUserException(jpe.getMessage(), jpe);
}
}
}
else if (jpe instanceof NucleusOptimisticException)
{
//sadly JDOOptimisticVerificationException dont allow nested exceptions and failed objects together
if (jpe.getFailedObject() != null)
{
return new JDOOptimisticVerificationException(jpe.getMessage(), jpe.getFailedObject());
}
else if (jpe.getNestedExceptions() != null)
{
return new JDOOptimisticVerificationException(jpe.getMessage(), jpe.getNestedExceptions());
}
else
{
return new JDOOptimisticVerificationException(jpe.getMessage(), jpe);
}
}
else if (jpe instanceof org.datanucleus.transaction.HeuristicRollbackException
&& jpe.getNestedExceptions().length==1
&& jpe.getNestedExceptions()[0].getCause() instanceof SQLException)
{
// if there was a single failure in the transaction, we want to properly propagate the
// single nested SQLException that was the cause of the failure, so application code
// can decide on what to do with it
return new JDODataStoreException(jpe.getMessage(), ((XAException)jpe.getNestedExceptions()[0]).getCause());
}
else
{
if (jpe.isFatal())
{