catch sort query exceptions
This commit is contained in:
@@ -120,8 +120,8 @@ public class GlobalExceptionHandler {
|
|||||||
return buildErrorResponse(HttpStatus.BAD_REQUEST, "Invalid sort field: " + ex.getPropertyName(), ex, request);
|
return buildErrorResponse(HttpStatus.BAD_REQUEST, "Invalid sort field: " + ex.getPropertyName(), ex, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(org.hibernate.query.PathException.class)
|
@ExceptionHandler({org.hibernate.query.PathException.class, org.hibernate.query.sqm.PathElementException.class})
|
||||||
public ResponseEntity<ApiErrorResponse> handleHibernatePathException(org.hibernate.query.PathException ex, HttpServletRequest request) {
|
public ResponseEntity<ApiErrorResponse> handleHibernatePathException(Exception ex, HttpServletRequest request) {
|
||||||
return buildErrorResponse(HttpStatus.BAD_REQUEST, "Invalid query field reference", ex, 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);
|
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)
|
@ExceptionHandler(Exception.class)
|
||||||
public ResponseEntity<ApiErrorResponse> handleGenericException(Exception ex, HttpServletRequest request) {
|
public ResponseEntity<ApiErrorResponse> handleGenericException(Exception ex, HttpServletRequest request) {
|
||||||
String message = ex.getMessage() == null || ex.getMessage().isBlank()
|
String message = ex.getMessage() == null || ex.getMessage().isBlank()
|
||||||
|
|||||||
Reference in New Issue
Block a user