use of org.springframework.dao.NonTransientDataAccessResourceException in project ORCID-Source by ORCID.
the class OrcidSearchManagerImpl method findPublicProfileById.
@Override
public OrcidMessage findPublicProfileById(String orcid) {
OrcidMessage om = null;
try {
if (cachingSource.equals(DB)) {
OrcidProfile orcidProfile = orcidProfileCacheManager.retrievePublic(orcid);
orcidProfile.setOrcidInternal(null);
om = new OrcidMessage(orcidProfile);
} else {
try (Reader reader = solrDao.findByOrcidAsReader(orcid)) {
if (reader != null) {
BufferedReader br = new BufferedReader(reader);
om = OrcidMessage.unmarshall(br);
}
}
}
} catch (NonTransientDataAccessResourceException e) {
throw new OrcidSearchException("Error searching by id: " + orcid, e);
} catch (IOException e) {
throw new OrcidSearchException("Error closing stream for id: " + orcid, e);
}
if (om == null)
throw new OrcidSearchException("Result is null");
return om;
}
use of org.springframework.dao.NonTransientDataAccessResourceException in project hedera-mirror-node by hashgraph.
the class ProtoUtilTest method toStatusRuntimeException.
@Test
void toStatusRuntimeException() {
var entityId = EntityId.of(1L, EntityType.ACCOUNT);
var message = "boom";
assertException(Exceptions.failWithOverflow(message), Status.DEADLINE_EXCEEDED, OVERFLOW_ERROR);
assertException(new ConstraintViolationException(message, null), Status.INVALID_ARGUMENT, message);
assertException(new IllegalArgumentException(message), Status.INVALID_ARGUMENT, message);
assertException(new InvalidEntityException(message), Status.INVALID_ARGUMENT, message);
assertException(new EntityNotFoundException(entityId), Status.NOT_FOUND, "Account 0.0.1 does not exist");
assertException(new NonTransientDataAccessResourceException(message), Status.UNAVAILABLE, DB_ERROR);
assertException(new QueryTimeoutException(message), Status.RESOURCE_EXHAUSTED, DB_ERROR);
assertException(new TimeoutException(message), Status.RESOURCE_EXHAUSTED, DB_ERROR);
assertException(new RuntimeException(message), Status.UNKNOWN, UNKNOWN_ERROR);
}
use of org.springframework.dao.NonTransientDataAccessResourceException in project dcache by dCache.
the class JdbcFs method inTransaction.
private <T> T inTransaction(FallibleTransactionCallback<T> callback) throws ChimeraFsException {
TransactionStatus status = _tx.getTransaction(_txDefinition);
T result;
try {
result = callback.doInTransaction(status);
_tx.commit(status);
} catch (ChimeraFsException e) {
rollbackOnException(status, e);
throw e;
} catch (NonTransientDataAccessResourceException e) {
rollbackOnException(status, e);
throw new BackEndErrorChimeraFsException(e.getMessage(), e);
} catch (DataAccessException e) {
rollbackOnException(status, e);
throw new ChimeraFsException(e.getMessage(), e);
} catch (Exception e) {
rollbackOnException(status, e);
throw e;
}
return result;
}
Aggregations