Class JaxrsValidationException

All Implemented Interfaces:
Serializable

public class JaxrsValidationException extends JaxrsException
Exception representing a 422 status code that extends JaxrsException to use Kiwi's ErrorMessage.
See Also:
  • Field Details

    • CODE

      public static final int CODE
      The status code for all instances of this exception.
      See Also:
  • Constructor Details

    • JaxrsValidationException

      public JaxrsValidationException(String itemId, List<Map<String,String>> errorMessageMaps)
      New instance with given item ID and error messages.

      Each map contained in errorMessageMaps must have entries with at least two keys: ErrorMessage.KEY_FIELD_NAME and ErrorMessage.KEY_MESSAGE. In other words, the maps should contain an entry whose key is ErrorMessage.KEY_FIELD_NAME and another entry whose key is ErrorMessage.KEY_MESSAGE. Any other entries are ignored. The value of these two entries become the field name and message in the resulting ErrorMessage objects.

      Parameters:
      itemId - the unique ID of the item that caused this error
      errorMessageMaps - a list containing maps containing
    • JaxrsValidationException

      public JaxrsValidationException(String itemId, Set<? extends jakarta.validation.ConstraintViolation<?>> violations)
      New instance with given item ID and constraint violations.
      Parameters:
      itemId - the unique ID of the item that caused this error
      violations - the constraint violations to transform into ErrorMessage objects
    • JaxrsValidationException

      public JaxrsValidationException(String itemId, Set<? extends jakarta.validation.ConstraintViolation<?>> violations, Map<String,String> propertyPathMappings)
      New instance with given item ID, constraint violations, and a map containing entries whose keys are the property path of the ConstraintViolation and values are the field/property name that should be used in place of the property path.

      For example, propertyPathMappings might contain an entry with key "firstName" and value "First Name". In the resulting instance, the corresponding ErrorMessage object contained in the list returned by JaxrsException.getErrors() will have "First Name" as the field name.

      Parameters:
      itemId - the unique ID of the item that caused this error
      violations - the constraint violations to transform into ErrorMessage objects
      propertyPathMappings - mappings from property path of a ConstraintViolation to the field name to use in the ErrorMessage objects
    • JaxrsValidationException

      public JaxrsValidationException(List<ErrorMessage> errorMessages)
      New instance with given ErrorMessage objects.

      It is assumed but not checked that the ErrorMessage objects are due to 422 errors. Therefore, it is possible to instantiate an instance with errors that have some other status code.

      Parameters:
      errorMessages - non-null list of error messages
  • Method Details