Class ValidationErrorsHandler


  • @RestControllerAdvice
    public class ValidationErrorsHandler
    extends Object
    Class for handling errors
    • Constructor Detail

      • ValidationErrorsHandler

        public ValidationErrorsHandler()
    • Method Detail

      • handleValidationException

        @ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class)
        @ResponseStatus(BAD_REQUEST)
        public ApiError handleValidationException​(org.springframework.web.bind.MethodArgumentNotValidException exception,
                                                  javax.servlet.http.HttpServletRequest request)
        Gets the response for MethodArgumentNotValidException
        Parameters:
        exception - MethodArgumentNotValidException
        request - http request
        Returns:
        api error response
      • handleCustomValidationException

        @ExceptionHandler(ValidationErrorException.class)
        @ResponseStatus(BAD_REQUEST)
        public ApiError handleCustomValidationException​(ValidationErrorException exception,
                                                        javax.servlet.http.HttpServletRequest request)
        Gets the response for ValidationErrorException custom exception
        Parameters:
        exception - ValidationErrorException
        request - http request
        Returns:
        api error response