// immediately throw errors
if (t instanceof Error)
throw (Error) t;
OpenJPAException ke;
if (!(t instanceof OpenJPAException)) {
if (!checked || t instanceof RuntimeException)
return t;
ke = new org.apache.openjpa.util.GeneralException(t.getMessage());
ke.setStackTrace(t.getStackTrace());
return ke;
}
// if only nested exception is a persistence one, return it directly
ke = (OpenJPAException) t;
if (ke.getNestedThrowables().length == 1
&& isPersistenceException(ke.getCause()))
return ke.getCause();
// RuntimeExceptions thrown from callbacks should be thrown directly
if (ke.getType() == OpenJPAException.USER
&& ke.getSubtype() == UserException.CALLBACK
&& ke.getNestedThrowables().length == 1) {
Throwable e = ke.getCause();
if (e instanceof InvocationTargetException)
e = e.getCause();
if (e instanceof RuntimeException)
return e;
}
// perform intelligent translation of openjpa exceptions
switch (ke.getType()) {
case OpenJPAException.STORE:
return translateStoreException(ke);
case OpenJPAException.USER:
return translateUserException(ke);
case OpenJPAException.WRAPPED: