@@ -0,0 +1,1551 @@
+package me.academeg.config;%0A%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.stereotype.Component;%0Aimport org.springframework.validation.FieldError;%0Aimport org.springframework.web.bind.MethodArgumentNotValidException;%0Aimport org.springframework.web.bind.annotation.ControllerAdvice;%0Aimport org.springframework.web.bind.annotation.ExceptionHandler;%0Aimport org.springframework.web.bind.annotation.ResponseBody;%0Aimport org.springframework.web.bind.annotation.ResponseStatus;%0A%0Aimport javax.validation.ConstraintViolation;%0Aimport javax.validation.ConstraintViolationException;%0Aimport java.util.Collections;%0Aimport java.util.Map;%0Aimport java.util.stream.Collectors;%0A%0A@ControllerAdvice%0A@Component%0Apublic class GlobalExceptionHandler %7B%0A%0A    @ExceptionHandler%0A    @ResponseBody%0A    @ResponseStatus(HttpStatus.BAD_REQUEST)%0A    public Map handle(MethodArgumentNotValidException exception) %7B%0A        return error(exception.getBindingResult().getFieldErrors()%0A                .stream()%0A                .map(FieldError::getDefaultMessage)%0A                .collect(Collectors.toList()));%0A    %7D%0A%0A%0A    @ExceptionHandler%0A    @ResponseBody%0A    @ResponseStatus(HttpStatus.BAD_REQUEST)%0A    public Map handle(ConstraintViolationException exception) %7B%0A        return error(exception.getConstraintViolations()%0A                .stream()%0A                .map(ConstraintViolation::getMessage)%0A                .collect(Collectors.toList()));%0A    %7D%0A%0A    private Map error(Object message) %7B%0A        return Collections.singletonMap(%22error%22, message);%0A    %7D%0A%7D%0A

Create primitive exception handler