Add logging for db execptons handling (#2155)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-12-19 16:37:57 +02:00
committed by GitHub
parent 52fec7c82b
commit 65ef31e702
2 changed files with 9 additions and 4 deletions

View File

@@ -71,9 +71,15 @@ public class ExceptionMappingAspectHandler implements Ordered {
// It is a AspectJ proxy which deals with exceptions.
@SuppressWarnings({ "squid:S00112", "squid:S1162" })
public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {
if (log.isTraceEnabled()) {
log.trace("Handling exception {}", ex.getClass().getName(), ex);
} else {
log.debug("Handling exception {}", ex.getClass().getName());
}
// Workaround for EclipseLink merge where it does not throw ConstraintViolationException directly in case of existing entity update
if (ex instanceof TransactionSystemException) {
throw replaceWithCauseIfConstraintViolationException((TransactionSystemException) ex);
if (ex instanceof TransactionSystemException transactionSystemException) {
throw replaceWithCauseIfConstraintViolationException(transactionSystemException);
}
for (final Class<?> mappedEx : MAPPED_EXCEPTION_ORDER) {

View File

@@ -279,7 +279,7 @@ public class RestConfiguration {
private void logRequest(final HttpServletRequest request, final Exception ex) {
if (log.isTraceEnabled()) {
log.debug("Handling exception {} of request {}", ex.getClass().getName(), request.getRequestURL(), ex);
log.trace("Handling exception {} of request {}", ex.getClass().getName(), request.getRequestURL(), ex);
} else {
log.debug("Handling exception {} of request {}", ex.getClass().getName(), request.getRequestURL());
}
@@ -334,5 +334,4 @@ public class RestConfiguration {
return false;
}
}
}