catch sort query exceptions

This commit is contained in:
2026-04-20 08:15:59 -06:00
parent ef7384515d
commit c346c9036f

View File

@@ -120,8 +120,8 @@ public class GlobalExceptionHandler {
return buildErrorResponse(HttpStatus.BAD_REQUEST, "Invalid sort field: " + ex.getPropertyName(), ex, request);
}
@ExceptionHandler(org.hibernate.query.PathException.class)
public ResponseEntity<ApiErrorResponse> handleHibernatePathException(org.hibernate.query.PathException ex, HttpServletRequest request) {
@ExceptionHandler({org.hibernate.query.PathException.class, org.hibernate.query.sqm.PathElementException.class})
public ResponseEntity<ApiErrorResponse> handleHibernatePathException(Exception ex, HttpServletRequest request) {
return buildErrorResponse(HttpStatus.BAD_REQUEST, "Invalid query field reference", ex, request);
}
@@ -150,6 +150,11 @@ public class GlobalExceptionHandler {
return buildErrorResponse(HttpStatus.BAD_REQUEST, ex.getMessage(), ex, request);
}
@ExceptionHandler(org.springframework.dao.InvalidDataAccessApiUsageException.class)
public ResponseEntity<ApiErrorResponse> handleInvalidDataAccess(org.springframework.dao.InvalidDataAccessApiUsageException ex, HttpServletRequest request) {
return buildErrorResponse(HttpStatus.BAD_REQUEST, "Invalid query or sort parameter", ex, request);
}
@ExceptionHandler(Exception.class)
public ResponseEntity<ApiErrorResponse> handleGenericException(Exception ex, HttpServletRequest request) {
String message = ex.getMessage() == null || ex.getMessage().isBlank()