/**
* Handle Not Found Exceptions.
*/
+ @ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler({NotFoundException.class})
- public static ResponseEntity<Object> handleNotFoundExceptions(final NotFoundException exception) {
+ public static String handleNotFoundExceptions(final NotFoundException exception) {
LOG.error("Request failed", exception);
- return ResponseEntity.notFound().build();
+ return exception.getMessage();
}
/**
@ExceptionHandler(MethodArgumentNotValidException.class)
public Map<String, String> handleValidationExceptions(final MethodArgumentNotValidException ex) {
final Map<String, String> errors = new HashMap<>();
- ex.getBindingResult().getAllErrors().forEach((error) -> {
+ ex.getBindingResult().getAllErrors().forEach(error -> {
final String fieldName = ((FieldError) error).getField();
final String errorMessage = error.getDefaultMessage();
errors.put(fieldName, errorMessage);