Class ValidationException

All Implemented Interfaces:
Serializable

public class ValidationException extends IllegalArgumentException
Exception used with Validator.

Typically this is used when validating a bean populated by request body content.

Generally this exception type is registered with an exception handler and configured to return a 422 or 400 http status response with the errors as a list of field error message.

See Also:
  • Constructor Details

    • ValidationException

      public ValidationException(String message)
      Create with a message.
    • ValidationException

      public ValidationException(int status, String message)
      Create with a status and message.
    • ValidationException

      public ValidationException(int status, String message, List<ValidationException.Violation> errors)
      Create with a status message and errors.
    • ValidationException

      public ValidationException(int status, String message, Throwable cause, List<ValidationException.Violation> errors)
      Create with a status message and errors.
  • Method Details

    • getStatus

      public int getStatus()
      Return the suggested HTTP status to use in the response.
    • getErrors

      public List<ValidationException.Violation> getErrors()
      Return the errors typically as a map of field to error message.