- return buildErrorResponse(HttpStatus.BAD_REQUEST, exception.getMessage(), extractDetails(exception));
+ return buildErrorResponse(HttpStatus.BAD_REQUEST, exception);
+ }
+
+ @ExceptionHandler({ValidationException.class})
+ public static ResponseEntity<Object> handleBadRequestExceptions(final ValidationException validationException) {
+ return buildErrorResponse(HttpStatus.BAD_REQUEST, validationException);
+ }
+
+ @ExceptionHandler({NotFoundInDataspaceException.class, DataNodeNotFoundException.class})
+ public static ResponseEntity<Object> handleNotFoundExceptions(final CpsException exception,
+ final HttpServletRequest request) {
+ return buildErrorResponse(HttpMethod.GET.matches(request.getMethod())
+ ? HttpStatus.NOT_FOUND : HttpStatus.BAD_REQUEST, exception);