Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging for db execptons handling #2155

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private static HttpStatus getStatusOrDefault(final SpServerError error) {

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());
}
Expand Down Expand Up @@ -334,5 +334,4 @@ private boolean shouldExclude(final HttpServletRequest request) {
return false;
}
}

}
Loading